mirror of
https://github.com/debba/avadaforms-excel-export.git
synced 2025-08-18 11:30:52 +08:00
First commit
This commit is contained in:
commit
9b83da904a
26 changed files with 2633 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.idea
|
339
LICENSE.txt
Normal file
339
LICENSE.txt
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
70
README.txt
Normal file
70
README.txt
Normal file
|
@ -0,0 +1,70 @@
|
|||
=== Plugin Name ===
|
||||
Contributors: dueclic
|
||||
Donate link: https://www.dueclic.com
|
||||
Tags: avada, forms, export, leads, database
|
||||
Requires at least: 3.0.1
|
||||
Tested up to: 3.4
|
||||
Stable tag: 4.3
|
||||
License: GPLv3
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Easily export your Avada Forms data to Excel / CSV .
|
||||
|
||||
== Description ==
|
||||
|
||||
Avada Forms to Excel / CSV allows you to export forms created with Avada in CSV or Excel in just a few steps.
|
||||
By simply installing the plugin, it will automatically add a button in Form Entries to esily download data.
|
||||
|
||||
### FEATURES
|
||||
|
||||
- No configuration is needed
|
||||
- Export form entries in CSV or Excel
|
||||
- Easy to use and lightweight plugin
|
||||
- Use filters to customize columns name and file name
|
||||
|
||||
== Languages ==
|
||||
* English
|
||||
* Italian
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Upload `avadaforms-excel-export.php` to the `/wp-content/plugins/` directory
|
||||
2. Activate the plugin through the 'Plugins' menu in WordPress
|
||||
3. Now in Avada Forms page you can easily export your data to Excel / CSV
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Can I customize field names? =
|
||||
Yes, for this purpose you can use the filter `avadaforms_export_fieldname`
|
||||
|
||||
`
|
||||
|
||||
function custom_fieldname($field_label,$form_id,$field){
|
||||
// $field_label is the current Label as defined in Avada Form Builder
|
||||
// $form_id is the Avada Form ID
|
||||
// $field is an object as {id: 'Avada Field ID', field_name: 'Avada Field Name', field_label: 'Avada Field Label as defined in Avada Form Builder'
|
||||
return $field_label;
|
||||
}
|
||||
|
||||
add_filter('avadaforms_export_fieldname', 'custom_fieldname',10, 3);
|
||||
`
|
||||
|
||||
= Can I customize file name? =
|
||||
Yes, for this purpose you can use the filter `avadaforms_export_filename`
|
||||
|
||||
`
|
||||
|
||||
function custom_filename($filename, $form_id){
|
||||
// $form_id is the Avada Form ID
|
||||
return $filename;
|
||||
}
|
||||
|
||||
add_filter('avadaforms_export_filename', 'custom_filename',10, 2);
|
||||
`
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.0 =
|
||||
* First version released
|
272
admin/class-avadaforms-excel-export-admin.php
Normal file
272
admin/class-avadaforms-excel-export-admin.php
Normal file
|
@ -0,0 +1,272 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The admin-specific functionality of the plugin.
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/admin
|
||||
*/
|
||||
|
||||
/**
|
||||
* The admin-specific functionality of the plugin.
|
||||
*
|
||||
* Defines the plugin name, version, and two examples hooks for how to
|
||||
* enqueue the admin-specific stylesheet and JavaScript.
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/admin
|
||||
* @author dueclic <info@dueclic.com>
|
||||
*/
|
||||
class Avadaforms_Excel_Export_Admin {
|
||||
|
||||
/**
|
||||
* The ID of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @var string $plugin_name The ID of this plugin.
|
||||
*/
|
||||
private $plugin_name;
|
||||
|
||||
/**
|
||||
* The version of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @var string $version The current version of this plugin.
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Initialize the class and set its properties.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $plugin_name The name of this plugin.
|
||||
* @param string $version The version of this plugin.
|
||||
*/
|
||||
public function __construct( $plugin_name, $version ) {
|
||||
|
||||
$this->plugin_name = $plugin_name;
|
||||
$this->version = $version;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the admin area.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function enqueue_styles() {
|
||||
|
||||
/**
|
||||
* This function is provided for demonstration purposes only.
|
||||
*
|
||||
* An instance of this class should be passed to the run() function
|
||||
* defined in Avadaforms_Excel_Export_Loader as all of the hooks are defined
|
||||
* in that particular class.
|
||||
*
|
||||
* The Avadaforms_Excel_Export_Loader will then create the relationship
|
||||
* between the defined hooks and the functions defined in this
|
||||
* class.
|
||||
*/
|
||||
|
||||
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/avadaforms-excel-export-admin.css', array(), $this->version, 'all' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the JavaScript for the admin area.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
|
||||
/**
|
||||
* This function is provided for demonstration purposes only.
|
||||
*
|
||||
* An instance of this class should be passed to the run() function
|
||||
* defined in Avadaforms_Excel_Export_Loader as all of the hooks are defined
|
||||
* in that particular class.
|
||||
*
|
||||
* The Avadaforms_Excel_Export_Loader will then create the relationship
|
||||
* between the defined hooks and the functions defined in this
|
||||
* class.
|
||||
*/
|
||||
|
||||
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/avadaforms-excel-export-admin.js', array( 'jquery' ), $this->version, false );
|
||||
|
||||
}
|
||||
|
||||
public function export_form()
|
||||
{
|
||||
if (isset($_GET[AVADAFORMS_EXCEL_EXPORT_FORMID_PARAM])
|
||||
&& isset($_GET['avadaform_export'])
|
||||
) {
|
||||
|
||||
$form_id = intval($_GET[AVADAFORMS_EXCEL_EXPORT_FORMID_PARAM]);
|
||||
|
||||
$submissions = new Fusion_Form_DB_Submissions();
|
||||
|
||||
$fusion_forms = new Fusion_Form_DB_Forms();
|
||||
$form_fields = $fusion_forms->get_form_fields($form_id);
|
||||
|
||||
$form_submissions = $submissions->get(
|
||||
[
|
||||
'where' => ['form_id' => $form_id],
|
||||
'limit' => -1,
|
||||
'order by' => 'id DESC',
|
||||
'offset' => 0,
|
||||
]
|
||||
);
|
||||
|
||||
$data = [];
|
||||
$form_entries = [];
|
||||
|
||||
$fusion_entries = new Fusion_Form_DB_Entries();
|
||||
|
||||
foreach ($form_submissions as $submission) {
|
||||
$form_entries[$submission->id] = $fusion_entries->get(
|
||||
[
|
||||
'where' => ['submission_id' => $submission->id],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$keys = [];
|
||||
|
||||
foreach ($form_entries as $key => $entries) {
|
||||
$entries = (array)$entries;
|
||||
|
||||
foreach ($entries as $entry) {
|
||||
$entry = (array)$entry;
|
||||
foreach ($form_fields as $field) {
|
||||
if (isset($entry['field_id'])
|
||||
&& $entry['field_id'] === $field->id
|
||||
) {
|
||||
$field_label = ''
|
||||
!== $field->field_label
|
||||
? $field->field_label : $field->field_name;
|
||||
$field_label = apply_filters(
|
||||
'avadaforms_export_fieldname', $field_label,
|
||||
$form_id, $field
|
||||
);
|
||||
$field_data = $entry['value'];
|
||||
$data[$key][$field_label] = $field_data;
|
||||
$keys[] = $field_label;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! isset($data[$key])) {
|
||||
$data[$key] = [];
|
||||
}
|
||||
}
|
||||
|
||||
$ext = (isset($_GET['format']) && $_GET['format'] == 'csv') ? 'csv' : 'xlsx';
|
||||
|
||||
$fileLocation = apply_filters(
|
||||
'avadaforms_export_filename', 'export-'.date("YmdHis"), $form_id
|
||||
).'.'.$ext;
|
||||
|
||||
// # prepare the data set
|
||||
$data = array_merge(
|
||||
[$keys],
|
||||
$data
|
||||
);
|
||||
|
||||
if ($ext == 'csv') {
|
||||
$fp = fopen($fileLocation, 'wb');
|
||||
|
||||
foreach ($data as $fields) {
|
||||
fputcsv($fp, $fields);
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
} else {
|
||||
$writer = new XLSXWriter();
|
||||
$writer->writeSheet($data);
|
||||
$writer->writeToFile($fileLocation);
|
||||
}
|
||||
|
||||
// # prompt download popup
|
||||
header('Content-Description: File Transfer');
|
||||
header(
|
||||
"Content-Type: ".($ext == 'csv' ? 'text/csv' : 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
|
||||
);
|
||||
header(
|
||||
"Content-Disposition: attachment; filename="
|
||||
.basename($fileLocation)
|
||||
);
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header("Expires: 0");
|
||||
header("Pragma: public");
|
||||
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
||||
header('Content-Length: '.filesize($fileLocation));
|
||||
|
||||
ob_clean();
|
||||
flush();
|
||||
|
||||
readfile($fileLocation);
|
||||
unlink($fileLocation);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function add_exportbutton()
|
||||
{
|
||||
if (isset($_GET[AVADAFORMS_EXCEL_EXPORT_FORMID_PARAM])) {
|
||||
?>
|
||||
<div style="margin-top:20px;margin-bottom:20px">
|
||||
<h2>
|
||||
<?php
|
||||
_e("Export options", "avadaforms-excel-export");
|
||||
?>
|
||||
</h2>
|
||||
|
||||
<label class="form-heading-inline" for="avada_export">
|
||||
<?php
|
||||
_e("Export as", "avadaforms-excel-export");
|
||||
?>
|
||||
<select id="avada_export_format">
|
||||
<option class="fusion-form">-- <?php
|
||||
_e("Select", "avadaforms-excel-export");
|
||||
?> --
|
||||
</option>
|
||||
<option class="fusion-form" value="csv">
|
||||
CSV
|
||||
</option>
|
||||
<option class="fusion-form"
|
||||
value="xlsx">
|
||||
XLSX
|
||||
</option>
|
||||
</select>
|
||||
<button class="button" role="button" onclick="document.location='<?php
|
||||
echo admin_url(); ?>?form_id=<?php
|
||||
echo absint(
|
||||
$_GET[AVADAFORMS_EXCEL_EXPORT_FORMID_PARAM]
|
||||
); ?>&avadaform_export=1&format='+document.getElementById('avada_export_format').value">
|
||||
<?php
|
||||
_e("Export", "avadaforms-excel-export");
|
||||
?>
|
||||
</button>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
public function add_action_links($links){
|
||||
return array_merge(
|
||||
$links,
|
||||
[
|
||||
'<a href="'.admin_url().'admin.php?page=avada-forms">'.__('Avada Forms', 'avadaforms-excel-export').'</a>'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
4
admin/css/avadaforms-excel-export-admin.css
Normal file
4
admin/css/avadaforms-excel-export-admin.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* All of the CSS for your admin-specific functionality should be
|
||||
* included in this file.
|
||||
*/
|
1
admin/index.php
Normal file
1
admin/index.php
Normal file
|
@ -0,0 +1 @@
|
|||
<?php // Silence is golden
|
32
admin/js/avadaforms-excel-export-admin.js
Normal file
32
admin/js/avadaforms-excel-export-admin.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
(function( $ ) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* All of the code for your admin-facing JavaScript source
|
||||
* should reside in this file.
|
||||
*
|
||||
* Note: It has been assumed you will write jQuery code here, so the
|
||||
* $ function reference has been prepared for usage within the scope
|
||||
* of this function.
|
||||
*
|
||||
* This enables you to define handlers, for when the DOM is ready:
|
||||
*
|
||||
* $(function() {
|
||||
*
|
||||
* });
|
||||
*
|
||||
* When the window is loaded:
|
||||
*
|
||||
* $( window ).load(function() {
|
||||
*
|
||||
* });
|
||||
*
|
||||
* ...and/or other possibilities.
|
||||
*
|
||||
* Ideally, it is not considered best practise to attach more than a
|
||||
* single DOM-ready or window-load handler for a particular page.
|
||||
* Although scripts in the WordPress core, Plugins and Themes may be
|
||||
* practising this, we should strive to set a better example in our own work.
|
||||
*/
|
||||
|
||||
})( jQuery );
|
16
admin/partials/avadaforms-excel-export-admin-display.php
Normal file
16
admin/partials/avadaforms-excel-export-admin-display.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Provide a admin area view for the plugin
|
||||
*
|
||||
* This file is used to markup the admin-facing aspects of the plugin.
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/admin/partials
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
|
88
avadaforms-excel-export.php
Normal file
88
avadaforms-excel-export.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The plugin bootstrap file
|
||||
*
|
||||
* This file is read by WordPress to generate the plugin information in the plugin
|
||||
* admin area. This file also includes all of the dependencies used by the plugin,
|
||||
* registers the activation and deactivation functions, and defines a function
|
||||
* that starts the plugin.
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
* @package Avadaforms_Excel_Export
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: Avada Forms to Excel / CSV
|
||||
* Plugin URI: https://www.dueclic.com
|
||||
* Description: Easily export your Avada Forms data to Excel / CSV
|
||||
* Version: 1.0.0
|
||||
* Author: dueclic
|
||||
* Author URI: https://www.dueclic.com
|
||||
* License: GPL-2.0+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
* Text Domain: avadaforms-excel-export
|
||||
* Domain Path: /languages
|
||||
*/
|
||||
|
||||
// If this file is called directly, abort.
|
||||
if ( ! defined('WPINC')) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently plugin version.
|
||||
* Start at version 1.0.0 and use SemVer - https://semver.org
|
||||
* Rename this for your plugin and update it as you release new versions.
|
||||
*/
|
||||
define('AVADAFORMS_EXCEL_EXPORT_VERSION', '1.0.0');
|
||||
define('AVADAFORMS_EXCEL_EXPORT_FORMID_PARAM', 'form_id');
|
||||
define( 'AVADAFORMS_EXCEL_EXPORT_FILE', __FILE__ );
|
||||
|
||||
/**
|
||||
* The code that runs during plugin activation.
|
||||
* This action is documented in includes/class-avadaforms-excel-export-activator.php
|
||||
*/
|
||||
function activate_avadaforms_excel_export()
|
||||
{
|
||||
require_once plugin_dir_path(__FILE__)
|
||||
.'includes/class-avadaforms-excel-export-activator.php';
|
||||
Avadaforms_Excel_Export_Activator::activate();
|
||||
}
|
||||
|
||||
/**
|
||||
* The code that runs during plugin deactivation.
|
||||
* This action is documented in includes/class-avadaforms-excel-export-deactivator.php
|
||||
*/
|
||||
function deactivate_avadaforms_excel_export()
|
||||
{
|
||||
require_once plugin_dir_path(__FILE__)
|
||||
.'includes/class-avadaforms-excel-export-deactivator.php';
|
||||
Avadaforms_Excel_Export_Deactivator::deactivate();
|
||||
}
|
||||
|
||||
register_activation_hook(__FILE__, 'activate_avadaforms_excel_export');
|
||||
register_deactivation_hook(__FILE__, 'deactivate_avadaforms_excel_export');
|
||||
|
||||
/**
|
||||
* The core plugin class that is used to define internationalization,
|
||||
* admin-specific hooks, and public-facing site hooks.
|
||||
*/
|
||||
require plugin_dir_path(__FILE__).'includes/class-avadaforms-excel-export.php';
|
||||
|
||||
/**
|
||||
* Begins execution of the plugin.
|
||||
*
|
||||
* Since everything within the plugin is registered via hooks,
|
||||
* then kicking off the plugin from this point in the file does
|
||||
* not affect the page life cycle.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
function run_avadaforms_excel_export()
|
||||
{
|
||||
$plugin = new Avadaforms_Excel_Export();
|
||||
$plugin->run();
|
||||
}
|
||||
|
||||
run_avadaforms_excel_export();
|
46
includes/class-avadaforms-excel-export-activator.php
Normal file
46
includes/class-avadaforms-excel-export-activator.php
Normal file
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Fired during plugin activation
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fired during plugin activation.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's activation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
* @author dueclic <info@dueclic.com>
|
||||
*/
|
||||
class Avadaforms_Excel_Export_Activator {
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function activate() {
|
||||
if ( ! class_exists('Fusion_Form_DB_Submissions')
|
||||
|| ! class_exists(
|
||||
'Fusion_Form_DB_Entries'
|
||||
)
|
||||
|| ! class_exists('Fusion_Form_DB_Forms')
|
||||
) {
|
||||
wp_die(
|
||||
__('Looks like Avada or Fusion Forms are not installed.', 'avadaforms-excel-export'),
|
||||
__('Avada Forms to Excel / CSV was not activated.', 'avadaforms-excel-export')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
36
includes/class-avadaforms-excel-export-deactivator.php
Normal file
36
includes/class-avadaforms-excel-export-deactivator.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Fired during plugin deactivation
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fired during plugin deactivation.
|
||||
*
|
||||
* This class defines all code necessary to run during the plugin's deactivation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
* @author dueclic <info@dueclic.com>
|
||||
*/
|
||||
class Avadaforms_Excel_Export_Deactivator {
|
||||
|
||||
/**
|
||||
* Short Description. (use period)
|
||||
*
|
||||
* Long Description.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function deactivate() {
|
||||
|
||||
}
|
||||
|
||||
}
|
47
includes/class-avadaforms-excel-export-i18n.php
Normal file
47
includes/class-avadaforms-excel-export-i18n.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Define the internationalization functionality
|
||||
*
|
||||
* Loads and defines the internationalization files for this plugin
|
||||
* so that it is ready for translation.
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Define the internationalization functionality.
|
||||
*
|
||||
* Loads and defines the internationalization files for this plugin
|
||||
* so that it is ready for translation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
* @author dueclic <info@dueclic.com>
|
||||
*/
|
||||
class Avadaforms_Excel_Export_i18n {
|
||||
|
||||
|
||||
/**
|
||||
* Load the plugin text domain for translation.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function load_plugin_textdomain() {
|
||||
|
||||
load_plugin_textdomain(
|
||||
'avadaforms-excel-export',
|
||||
false,
|
||||
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
129
includes/class-avadaforms-excel-export-loader.php
Normal file
129
includes/class-avadaforms-excel-export-loader.php
Normal file
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Register all actions and filters for the plugin
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* Register all actions and filters for the plugin.
|
||||
*
|
||||
* Maintain a list of all hooks that are registered throughout
|
||||
* the plugin, and register them with the WordPress API. Call the
|
||||
* run function to execute the list of actions and filters.
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
* @author dueclic <info@dueclic.com>
|
||||
*/
|
||||
class Avadaforms_Excel_Export_Loader {
|
||||
|
||||
/**
|
||||
* The array of actions registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $actions;
|
||||
|
||||
/**
|
||||
* The array of filters registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
||||
*/
|
||||
protected $filters;
|
||||
|
||||
/**
|
||||
* Initialize the collections used to maintain the actions and filters.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->actions = array();
|
||||
$this->filters = array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new action to the collection to be registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $hook The name of the WordPress action that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the action is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
||||
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
||||
*/
|
||||
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
||||
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new filter to the collection to be registered with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $hook The name of the WordPress filter that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
||||
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
|
||||
*/
|
||||
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
||||
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility function that is used to register the actions and hooks into a single
|
||||
* collection.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
||||
* @param string $hook The name of the WordPress filter that is being registered.
|
||||
* @param object $component A reference to the instance of the object on which the filter is defined.
|
||||
* @param string $callback The name of the function definition on the $component.
|
||||
* @param int $priority The priority at which the function should be fired.
|
||||
* @param int $accepted_args The number of arguments that should be passed to the $callback.
|
||||
* @return array The collection of actions and filters registered with WordPress.
|
||||
*/
|
||||
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
||||
|
||||
$hooks[] = array(
|
||||
'hook' => $hook,
|
||||
'component' => $component,
|
||||
'callback' => $callback,
|
||||
'priority' => $priority,
|
||||
'accepted_args' => $accepted_args
|
||||
);
|
||||
|
||||
return $hooks;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the filters and actions with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function run() {
|
||||
|
||||
foreach ( $this->filters as $hook ) {
|
||||
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
||||
}
|
||||
|
||||
foreach ( $this->actions as $hook ) {
|
||||
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
250
includes/class-avadaforms-excel-export.php
Normal file
250
includes/class-avadaforms-excel-export.php
Normal file
|
@ -0,0 +1,250 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The file that defines the core plugin class
|
||||
*
|
||||
* A class definition that includes attributes and functions used across both the
|
||||
* public-facing side of the site and the admin area.
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
*/
|
||||
|
||||
/**
|
||||
* The core plugin class.
|
||||
*
|
||||
* This is used to define internationalization, admin-specific hooks, and
|
||||
* public-facing site hooks.
|
||||
*
|
||||
* Also maintains the unique identifier of this plugin as well as the current
|
||||
* version of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/includes
|
||||
* @author dueclic <info@dueclic.com>
|
||||
*/
|
||||
class Avadaforms_Excel_Export
|
||||
{
|
||||
|
||||
/**
|
||||
* The loader that's responsible for maintaining and registering all hooks that power
|
||||
* the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var Avadaforms_Excel_Export_Loader $loader Maintains and registers all hooks for the plugin.
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
/**
|
||||
* The unique identifier of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var string $plugin_name The string used to uniquely identify this plugin.
|
||||
*/
|
||||
protected $plugin_name;
|
||||
|
||||
/**
|
||||
* The current version of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var string $version The current version of the plugin.
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* Define the core functionality of the plugin.
|
||||
*
|
||||
* Set the plugin name and the plugin version that can be used throughout the plugin.
|
||||
* Load the dependencies, define the locale, and set the hooks for the admin area and
|
||||
* the public-facing side of the site.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (defined('AVADAFORMS_EXCEL_EXPORT_VERSION')) {
|
||||
$this->version = AVADAFORMS_EXCEL_EXPORT_VERSION;
|
||||
} else {
|
||||
$this->version = '1.0.0';
|
||||
}
|
||||
$this->plugin_name = 'avadaforms-excel-export';
|
||||
|
||||
$this->load_dependencies();
|
||||
$this->set_locale();
|
||||
$this->define_admin_hooks();
|
||||
$this->define_public_hooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the required dependencies for this plugin.
|
||||
*
|
||||
* Include the following files that make up the plugin:
|
||||
*
|
||||
* - Avadaforms_Excel_Export_Loader. Orchestrates the hooks of the plugin.
|
||||
* - Avadaforms_Excel_Export_i18n. Defines internationalization functionality.
|
||||
* - Avadaforms_Excel_Export_Admin. Defines all hooks for the admin area.
|
||||
* - Avadaforms_Excel_Export_Public. Defines all hooks for the public side of the site.
|
||||
*
|
||||
* Create an instance of the loader which will be used to register the hooks
|
||||
* with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function load_dependencies()
|
||||
{
|
||||
/**
|
||||
* The class responsible for orchestrating the actions and filters of the
|
||||
* core plugin.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__))
|
||||
.'includes/class-avadaforms-excel-export-loader.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining internationalization functionality
|
||||
* of the plugin.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__))
|
||||
.'includes/class-avadaforms-excel-export-i18n.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining all actions that occur in the admin area.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__))
|
||||
.'admin/class-avadaforms-excel-export-admin.php';
|
||||
|
||||
/**
|
||||
* The class responsible for defining all actions that occur in the public-facing
|
||||
* side of the site.
|
||||
*/
|
||||
require_once plugin_dir_path(dirname(__FILE__))
|
||||
.'public/class-avadaforms-excel-export-public.php';
|
||||
|
||||
require_once plugin_dir_path(dirname(__FILE__))
|
||||
.'includes/xlswriter.class.php';
|
||||
|
||||
$this->loader = new Avadaforms_Excel_Export_Loader();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the locale for this plugin for internationalization.
|
||||
*
|
||||
* Uses the Avadaforms_Excel_Export_i18n class in order to set the domain and to register the hook
|
||||
* with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function set_locale()
|
||||
{
|
||||
$plugin_i18n = new Avadaforms_Excel_Export_i18n();
|
||||
|
||||
$this->loader->add_action(
|
||||
'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all of the hooks related to the admin area functionality
|
||||
* of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function define_admin_hooks()
|
||||
{
|
||||
$plugin_admin = new Avadaforms_Excel_Export_Admin(
|
||||
$this->get_plugin_name(), $this->get_version()
|
||||
);
|
||||
|
||||
$this->loader->add_action(
|
||||
'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'
|
||||
);
|
||||
$this->loader->add_action(
|
||||
'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'
|
||||
);
|
||||
$this->loader->add_action('admin_init', $plugin_admin, 'export_form');
|
||||
$this->loader->add_action(
|
||||
'fusion_form_admin_text', $plugin_admin, 'add_exportbutton'
|
||||
);
|
||||
|
||||
$this->loader->add_action(
|
||||
'plugin_action_links_'.plugin_basename(AVADAFORMS_EXCEL_EXPORT_FILE),
|
||||
$plugin_admin,
|
||||
'add_action_links'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all of the hooks related to the public-facing functionality
|
||||
* of the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
*/
|
||||
private function define_public_hooks()
|
||||
{
|
||||
$plugin_public = new Avadaforms_Excel_Export_Public(
|
||||
$this->get_plugin_name(), $this->get_version()
|
||||
);
|
||||
|
||||
$this->loader->add_action(
|
||||
'wp_enqueue_scripts', $plugin_public, 'enqueue_styles'
|
||||
);
|
||||
$this->loader->add_action(
|
||||
'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the loader to execute all of the hooks with WordPress.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$this->loader->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the plugin used to uniquely identify it within the context of
|
||||
* WordPress and to define internationalization functionality.
|
||||
*
|
||||
* @return string The name of the plugin.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function get_plugin_name()
|
||||
{
|
||||
return $this->plugin_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reference to the class that orchestrates the hooks with the plugin.
|
||||
*
|
||||
* @return Avadaforms_Excel_Export_Loader Orchestrates the hooks of the plugin.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function get_loader()
|
||||
{
|
||||
return $this->loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the version number of the plugin.
|
||||
*
|
||||
* @return string The version number of the plugin.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function get_version()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
}
|
1
includes/index.php
Normal file
1
includes/index.php
Normal file
|
@ -0,0 +1 @@
|
|||
<?php // Silence is golden
|
979
includes/xlswriter.class.php
Normal file
979
includes/xlswriter.class.php
Normal file
|
@ -0,0 +1,979 @@
|
|||
<?php
|
||||
/*
|
||||
* @license MIT License
|
||||
* */
|
||||
|
||||
class XLSXWriter
|
||||
{
|
||||
//http://www.ecma-international.org/publications/standards/Ecma-376.htm
|
||||
//http://officeopenxml.com/SSstyles.php
|
||||
//------------------------------------------------------------------
|
||||
//http://office.microsoft.com/en-us/excel-help/excel-specifications-and-limits-HP010073849.aspx
|
||||
const EXCEL_2007_MAX_ROW=1048576;
|
||||
const EXCEL_2007_MAX_COL=16384;
|
||||
//------------------------------------------------------------------
|
||||
protected $title;
|
||||
protected $subject;
|
||||
protected $author;
|
||||
protected $isRightToLeft;
|
||||
protected $company;
|
||||
protected $description;
|
||||
protected $keywords = array();
|
||||
|
||||
protected $current_sheet;
|
||||
protected $sheets = array();
|
||||
protected $temp_files = array();
|
||||
protected $cell_styles = array();
|
||||
protected $number_formats = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
defined('ENT_XML1') or define('ENT_XML1',16);//for php 5.3, avoid fatal error
|
||||
date_default_timezone_get() or date_default_timezone_set('UTC');//php.ini missing tz, avoid warning
|
||||
is_writeable($this->tempFilename()) or self::log("Warning: tempdir ".sys_get_temp_dir()." not writeable, use ->setTempDir()");
|
||||
class_exists('ZipArchive') or self::log("Error: ZipArchive class does not exist");
|
||||
$this->addCellStyle($number_format='GENERAL', $style_string=null);
|
||||
}
|
||||
|
||||
public function setTitle($title='') { $this->title=$title; }
|
||||
public function setSubject($subject='') { $this->subject=$subject; }
|
||||
public function setAuthor($author='') { $this->author=$author; }
|
||||
public function setCompany($company='') { $this->company=$company; }
|
||||
public function setKeywords($keywords='') { $this->keywords=$keywords; }
|
||||
public function setDescription($description='') { $this->description=$description; }
|
||||
public function setTempDir($tempdir='') { $this->tempdir=$tempdir; }
|
||||
public function setRightToLeft($isRightToLeft=false){ $this->isRightToLeft=$isRightToLeft; }
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (!empty($this->temp_files)) {
|
||||
foreach($this->temp_files as $temp_file) {
|
||||
@unlink($temp_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function tempFilename()
|
||||
{
|
||||
$tempdir = !empty($this->tempdir) ? $this->tempdir : sys_get_temp_dir();
|
||||
$filename = tempnam($tempdir, "xlsx_writer_");
|
||||
if (!$filename) {
|
||||
// If you are seeing this error, it's possible you may have too many open
|
||||
// file handles. If you're creating a spreadsheet with many small inserts,
|
||||
// it is possible to exceed the default 1024 open file handles. Run 'ulimit -a'
|
||||
// and try increasing the 'open files' number with 'ulimit -n 8192'
|
||||
throw new \Exception("Unable to create tempfile - check file handle limits?");
|
||||
}
|
||||
$this->temp_files[] = $filename;
|
||||
return $filename;
|
||||
}
|
||||
|
||||
public function writeToStdOut()
|
||||
{
|
||||
$temp_file = $this->tempFilename();
|
||||
self::writeToFile($temp_file);
|
||||
readfile($temp_file);
|
||||
}
|
||||
|
||||
public function writeToString()
|
||||
{
|
||||
$temp_file = $this->tempFilename();
|
||||
self::writeToFile($temp_file);
|
||||
$string = file_get_contents($temp_file);
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function writeToFile($filename)
|
||||
{
|
||||
foreach($this->sheets as $sheet_name => $sheet) {
|
||||
self::finalizeSheet($sheet_name);//making sure all footers have been written
|
||||
}
|
||||
|
||||
if ( file_exists( $filename ) ) {
|
||||
if ( is_writable( $filename ) ) {
|
||||
@unlink( $filename ); //if the zip already exists, remove it
|
||||
} else {
|
||||
self::log( "Error in " . __CLASS__ . "::" . __FUNCTION__ . ", file is not writeable." );
|
||||
return;
|
||||
}
|
||||
}
|
||||
$zip = new ZipArchive();
|
||||
if (empty($this->sheets)) { self::log("Error in ".__CLASS__."::".__FUNCTION__.", no worksheets defined."); return; }
|
||||
if (!$zip->open($filename, ZipArchive::CREATE)) { self::log("Error in ".__CLASS__."::".__FUNCTION__.", unable to create zip."); return; }
|
||||
|
||||
$zip->addEmptyDir("docProps/");
|
||||
$zip->addFromString("docProps/app.xml" , self::buildAppXML() );
|
||||
$zip->addFromString("docProps/core.xml", self::buildCoreXML());
|
||||
|
||||
$zip->addEmptyDir("_rels/");
|
||||
$zip->addFromString("_rels/.rels", self::buildRelationshipsXML());
|
||||
|
||||
$zip->addEmptyDir("xl/worksheets/");
|
||||
foreach($this->sheets as $sheet) {
|
||||
$zip->addFile($sheet->filename, "xl/worksheets/".$sheet->xmlname );
|
||||
}
|
||||
$zip->addFromString("xl/workbook.xml" , self::buildWorkbookXML() );
|
||||
$zip->addFile($this->writeStylesXML(), "xl/styles.xml" ); //$zip->addFromString("xl/styles.xml" , self::buildStylesXML() );
|
||||
$zip->addFromString("[Content_Types].xml" , self::buildContentTypesXML() );
|
||||
|
||||
$zip->addEmptyDir("xl/_rels/");
|
||||
$zip->addFromString("xl/_rels/workbook.xml.rels", self::buildWorkbookRelsXML() );
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
protected function initializeSheet($sheet_name, $col_widths=array(), $auto_filter=false, $freeze_rows=false, $freeze_columns=false )
|
||||
{
|
||||
//if already initialized
|
||||
if ($this->current_sheet==$sheet_name || isset($this->sheets[$sheet_name]))
|
||||
return;
|
||||
|
||||
$sheet_filename = $this->tempFilename();
|
||||
$sheet_xmlname = 'sheet' . (count($this->sheets) + 1).".xml";
|
||||
$this->sheets[$sheet_name] = (object)array(
|
||||
'filename' => $sheet_filename,
|
||||
'sheetname' => $sheet_name,
|
||||
'xmlname' => $sheet_xmlname,
|
||||
'row_count' => 0,
|
||||
'file_writer' => new XLSXWriter_BuffererWriter($sheet_filename),
|
||||
'columns' => array(),
|
||||
'merge_cells' => array(),
|
||||
'max_cell_tag_start' => 0,
|
||||
'max_cell_tag_end' => 0,
|
||||
'auto_filter' => $auto_filter,
|
||||
'freeze_rows' => $freeze_rows,
|
||||
'freeze_columns' => $freeze_columns,
|
||||
'finalized' => false,
|
||||
);
|
||||
$rightToLeftValue = $this->isRightToLeft ? 'true' : 'false';
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
$tabselected = count($this->sheets) == 1 ? 'true' : 'false';//only first sheet is selected
|
||||
$max_cell=XLSXWriter::xlsCell(self::EXCEL_2007_MAX_ROW, self::EXCEL_2007_MAX_COL);//XFE1048577
|
||||
$sheet->file_writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n");
|
||||
$sheet->file_writer->write('<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">');
|
||||
$sheet->file_writer->write( '<sheetPr filterMode="false">');
|
||||
$sheet->file_writer->write( '<pageSetUpPr fitToPage="false"/>');
|
||||
$sheet->file_writer->write( '</sheetPr>');
|
||||
$sheet->max_cell_tag_start = $sheet->file_writer->ftell();
|
||||
$sheet->file_writer->write('<dimension ref="A1:' . $max_cell . '"/>');
|
||||
$sheet->max_cell_tag_end = $sheet->file_writer->ftell();
|
||||
$sheet->file_writer->write( '<sheetViews>');
|
||||
$sheet->file_writer->write( '<sheetView colorId="64" defaultGridColor="true" rightToLeft="'.$rightToLeftValue.'" showFormulas="false" showGridLines="true" showOutlineSymbols="true" showRowColHeaders="true" showZeros="true" tabSelected="' . $tabselected . '" topLeftCell="A1" view="normal" windowProtection="false" workbookViewId="0" zoomScale="100" zoomScaleNormal="100" zoomScalePageLayoutView="100">');
|
||||
if ($sheet->freeze_rows && $sheet->freeze_columns) {
|
||||
$sheet->file_writer->write( '<pane ySplit="'.$sheet->freeze_rows.'" xSplit="'.$sheet->freeze_columns.'" topLeftCell="'.self::xlsCell($sheet->freeze_rows, $sheet->freeze_columns).'" activePane="bottomRight" state="frozen"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell($sheet->freeze_rows, 0).'" activeCellId="0" pane="topRight" sqref="'.self::xlsCell($sheet->freeze_rows, 0).'"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell(0, $sheet->freeze_columns).'" activeCellId="0" pane="bottomLeft" sqref="'.self::xlsCell(0, $sheet->freeze_columns).'"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell($sheet->freeze_rows, $sheet->freeze_columns).'" activeCellId="0" pane="bottomRight" sqref="'.self::xlsCell($sheet->freeze_rows, $sheet->freeze_columns).'"/>');
|
||||
}
|
||||
elseif ($sheet->freeze_rows) {
|
||||
$sheet->file_writer->write( '<pane ySplit="'.$sheet->freeze_rows.'" topLeftCell="'.self::xlsCell($sheet->freeze_rows, 0).'" activePane="bottomLeft" state="frozen"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell($sheet->freeze_rows, 0).'" activeCellId="0" pane="bottomLeft" sqref="'.self::xlsCell($sheet->freeze_rows, 0).'"/>');
|
||||
}
|
||||
elseif ($sheet->freeze_columns) {
|
||||
$sheet->file_writer->write( '<pane xSplit="'.$sheet->freeze_columns.'" topLeftCell="'.self::xlsCell(0, $sheet->freeze_columns).'" activePane="topRight" state="frozen"/>');
|
||||
$sheet->file_writer->write( '<selection activeCell="'.self::xlsCell(0, $sheet->freeze_columns).'" activeCellId="0" pane="topRight" sqref="'.self::xlsCell(0, $sheet->freeze_columns).'"/>');
|
||||
}
|
||||
else { // not frozen
|
||||
$sheet->file_writer->write( '<selection activeCell="A1" activeCellId="0" pane="topLeft" sqref="A1"/>');
|
||||
}
|
||||
$sheet->file_writer->write( '</sheetView>');
|
||||
$sheet->file_writer->write( '</sheetViews>');
|
||||
$sheet->file_writer->write( '<cols>');
|
||||
$i=0;
|
||||
if (!empty($col_widths)) {
|
||||
foreach($col_widths as $column_width) {
|
||||
$sheet->file_writer->write( '<col collapsed="false" hidden="false" max="'.($i+1).'" min="'.($i+1).'" style="0" customWidth="true" width="'.floatval($column_width).'"/>');
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$sheet->file_writer->write( '<col collapsed="false" hidden="false" max="1024" min="'.($i+1).'" style="0" customWidth="false" width="11.5"/>');
|
||||
$sheet->file_writer->write( '</cols>');
|
||||
$sheet->file_writer->write( '<sheetData>');
|
||||
}
|
||||
|
||||
private function addCellStyle($number_format, $cell_style_string)
|
||||
{
|
||||
$number_format_idx = self::add_to_list_get_index($this->number_formats, $number_format);
|
||||
$lookup_string = $number_format_idx.";".$cell_style_string;
|
||||
$cell_style_idx = self::add_to_list_get_index($this->cell_styles, $lookup_string);
|
||||
return $cell_style_idx;
|
||||
}
|
||||
|
||||
private function initializeColumnTypes($header_types)
|
||||
{
|
||||
$column_types = array();
|
||||
foreach($header_types as $v)
|
||||
{
|
||||
$number_format = self::numberFormatStandardized($v);
|
||||
$number_format_type = self::determineNumberFormatType($number_format);
|
||||
$cell_style_idx = $this->addCellStyle($number_format, $style_string=null);
|
||||
$column_types[] = array('number_format' => $number_format,//contains excel format like 'YYYY-MM-DD HH:MM:SS'
|
||||
'number_format_type' => $number_format_type, //contains friendly format like 'datetime'
|
||||
'default_cell_style' => $cell_style_idx,
|
||||
);
|
||||
}
|
||||
return $column_types;
|
||||
}
|
||||
|
||||
public function writeSheetHeader($sheet_name, array $header_types, $col_options = null)
|
||||
{
|
||||
if (empty($sheet_name) || empty($header_types) || !empty($this->sheets[$sheet_name]))
|
||||
return;
|
||||
|
||||
$suppress_row = isset($col_options['suppress_row']) ? intval($col_options['suppress_row']) : false;
|
||||
if (is_bool($col_options))
|
||||
{
|
||||
self::log( "Warning! passing $suppress_row=false|true to writeSheetHeader() is deprecated, this will be removed in a future version." );
|
||||
$suppress_row = intval($col_options);
|
||||
}
|
||||
$style = &$col_options;
|
||||
|
||||
$col_widths = isset($col_options['widths']) ? (array)$col_options['widths'] : array();
|
||||
$auto_filter = isset($col_options['auto_filter']) ? intval($col_options['auto_filter']) : false;
|
||||
$freeze_rows = isset($col_options['freeze_rows']) ? intval($col_options['freeze_rows']) : false;
|
||||
$freeze_columns = isset($col_options['freeze_columns']) ? intval($col_options['freeze_columns']) : false;
|
||||
self::initializeSheet($sheet_name, $col_widths, $auto_filter, $freeze_rows, $freeze_columns);
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
$sheet->columns = $this->initializeColumnTypes($header_types);
|
||||
if (!$suppress_row)
|
||||
{
|
||||
$header_row = array_keys($header_types);
|
||||
|
||||
$sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . (1) . '">');
|
||||
foreach ($header_row as $c => $v) {
|
||||
$cell_style_idx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle( 'GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style) );
|
||||
$this->writeCell($sheet->file_writer, 0, $c, $v, $number_format_type='n_string', $cell_style_idx);
|
||||
}
|
||||
$sheet->file_writer->write('</row>');
|
||||
$sheet->row_count++;
|
||||
}
|
||||
$this->current_sheet = $sheet_name;
|
||||
}
|
||||
|
||||
public function writeSheetRow($sheet_name, array $row, $row_options=null)
|
||||
{
|
||||
if (empty($sheet_name))
|
||||
return;
|
||||
|
||||
$this->initializeSheet($sheet_name);
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
if (count($sheet->columns) < count($row)) {
|
||||
$default_column_types = $this->initializeColumnTypes( array_fill($from=0, $until=count($row), 'GENERAL') );//will map to n_auto
|
||||
$sheet->columns = array_merge((array)$sheet->columns, $default_column_types);
|
||||
}
|
||||
|
||||
if (!empty($row_options))
|
||||
{
|
||||
$ht = isset($row_options['height']) ? floatval($row_options['height']) : 12.1;
|
||||
$customHt = isset($row_options['height']) ? true : false;
|
||||
$hidden = isset($row_options['hidden']) ? (bool)($row_options['hidden']) : false;
|
||||
$collapsed = isset($row_options['collapsed']) ? (bool)($row_options['collapsed']) : false;
|
||||
$sheet->file_writer->write('<row collapsed="'.($collapsed).'" customFormat="false" customHeight="'.($customHt).'" hidden="'.($hidden).'" ht="'.($ht).'" outlineLevel="0" r="' . ($sheet->row_count + 1) . '">');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sheet->file_writer->write('<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . ($sheet->row_count + 1) . '">');
|
||||
}
|
||||
|
||||
$style = &$row_options;
|
||||
$c=0;
|
||||
foreach ($row as $v) {
|
||||
$number_format = $sheet->columns[$c]['number_format'];
|
||||
$number_format_type = $sheet->columns[$c]['number_format_type'];
|
||||
$cell_style_idx = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle( $number_format, json_encode(isset($style[0]) ? $style[$c] : $style) );
|
||||
$this->writeCell($sheet->file_writer, $sheet->row_count, $c, $v, $number_format_type, $cell_style_idx);
|
||||
$c++;
|
||||
}
|
||||
$sheet->file_writer->write('</row>');
|
||||
$sheet->row_count++;
|
||||
$this->current_sheet = $sheet_name;
|
||||
}
|
||||
|
||||
public function countSheetRows($sheet_name = '')
|
||||
{
|
||||
$sheet_name = $sheet_name ? $sheet_name : $this->current_sheet;
|
||||
return array_key_exists($sheet_name, $this->sheets) ? $this->sheets[$sheet_name]->row_count : 0;
|
||||
}
|
||||
|
||||
protected function finalizeSheet($sheet_name)
|
||||
{
|
||||
if (empty($sheet_name) || $this->sheets[$sheet_name]->finalized)
|
||||
return;
|
||||
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
|
||||
$sheet->file_writer->write( '</sheetData>');
|
||||
|
||||
if (!empty($sheet->merge_cells)) {
|
||||
$sheet->file_writer->write( '<mergeCells>');
|
||||
foreach ($sheet->merge_cells as $range) {
|
||||
$sheet->file_writer->write( '<mergeCell ref="' . $range . '"/>');
|
||||
}
|
||||
$sheet->file_writer->write( '</mergeCells>');
|
||||
}
|
||||
|
||||
$max_cell = self::xlsCell($sheet->row_count - 1, count($sheet->columns) - 1);
|
||||
|
||||
if ($sheet->auto_filter) {
|
||||
$sheet->file_writer->write( '<autoFilter ref="A1:' . $max_cell . '"/>');
|
||||
}
|
||||
|
||||
$sheet->file_writer->write( '<printOptions headings="false" gridLines="false" gridLinesSet="true" horizontalCentered="false" verticalCentered="false"/>');
|
||||
$sheet->file_writer->write( '<pageMargins left="0.5" right="0.5" top="1.0" bottom="1.0" header="0.5" footer="0.5"/>');
|
||||
$sheet->file_writer->write( '<pageSetup blackAndWhite="false" cellComments="none" copies="1" draft="false" firstPageNumber="1" fitToHeight="1" fitToWidth="1" horizontalDpi="300" orientation="portrait" pageOrder="downThenOver" paperSize="1" scale="100" useFirstPageNumber="true" usePrinterDefaults="false" verticalDpi="300"/>');
|
||||
$sheet->file_writer->write( '<headerFooter differentFirst="false" differentOddEven="false">');
|
||||
$sheet->file_writer->write( '<oddHeader>&C&"Times New Roman,Regular"&12&A</oddHeader>');
|
||||
$sheet->file_writer->write( '<oddFooter>&C&"Times New Roman,Regular"&12Page &P</oddFooter>');
|
||||
$sheet->file_writer->write( '</headerFooter>');
|
||||
$sheet->file_writer->write('</worksheet>');
|
||||
|
||||
$max_cell_tag = '<dimension ref="A1:' . $max_cell . '"/>';
|
||||
$padding_length = $sheet->max_cell_tag_end - $sheet->max_cell_tag_start - strlen($max_cell_tag);
|
||||
$sheet->file_writer->fseek($sheet->max_cell_tag_start);
|
||||
$sheet->file_writer->write($max_cell_tag.str_repeat(" ", $padding_length));
|
||||
$sheet->file_writer->close();
|
||||
$sheet->finalized=true;
|
||||
}
|
||||
|
||||
public function markMergedCell($sheet_name, $start_cell_row, $start_cell_column, $end_cell_row, $end_cell_column)
|
||||
{
|
||||
if (empty($sheet_name) || $this->sheets[$sheet_name]->finalized)
|
||||
return;
|
||||
|
||||
self::initializeSheet($sheet_name);
|
||||
$sheet = &$this->sheets[$sheet_name];
|
||||
|
||||
$startCell = self::xlsCell($start_cell_row, $start_cell_column);
|
||||
$endCell = self::xlsCell($end_cell_row, $end_cell_column);
|
||||
$sheet->merge_cells[] = $startCell . ":" . $endCell;
|
||||
}
|
||||
|
||||
public function writeSheet(array $data, $sheet_name='', array $header_types=array())
|
||||
{
|
||||
$sheet_name = empty($sheet_name) ? 'Sheet1' : $sheet_name;
|
||||
$data = empty($data) ? array(array('')) : $data;
|
||||
if (!empty($header_types))
|
||||
{
|
||||
$this->writeSheetHeader($sheet_name, $header_types);
|
||||
}
|
||||
foreach($data as $i=>$row)
|
||||
{
|
||||
$this->writeSheetRow($sheet_name, $row);
|
||||
}
|
||||
$this->finalizeSheet($sheet_name);
|
||||
}
|
||||
|
||||
protected function writeCell(XLSXWriter_BuffererWriter &$file, $row_number, $column_number, $value, $num_format_type, $cell_style_idx)
|
||||
{
|
||||
$cell_name = self::xlsCell($row_number, $column_number);
|
||||
|
||||
if (!is_scalar($value) || $value==='') { //objects, array, empty
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'"/>');
|
||||
} elseif (is_string($value) && $value[0]=='='){
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="s"><f>'.self::xmlspecialchars($value).'</f></c>');
|
||||
} elseif ($num_format_type=='n_date') {
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.intval(self::convert_date_time($value)).'</v></c>');
|
||||
} elseif ($num_format_type=='n_datetime') {
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::convert_date_time($value).'</v></c>');
|
||||
} elseif ($num_format_type=='n_numeric') {
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::xmlspecialchars($value).'</v></c>');//int,float,currency
|
||||
} elseif ($num_format_type=='n_string') {
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="inlineStr"><is><t>'.self::xmlspecialchars($value).'</t></is></c>');
|
||||
} elseif ($num_format_type=='n_auto' || 1) { //auto-detect unknown column types
|
||||
if (!is_string($value) || $value=='0' || ($value[0]!='0' && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)(\.[0-9]+)?$/", $value)){
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="n"><v>'.self::xmlspecialchars($value).'</v></c>');//int,float,currency
|
||||
} else { //implied: ($cell_format=='string')
|
||||
$file->write('<c r="'.$cell_name.'" s="'.$cell_style_idx.'" t="inlineStr"><is><t>'.self::xmlspecialchars($value).'</t></is></c>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function styleFontIndexes()
|
||||
{
|
||||
static $border_allowed = array('left','right','top','bottom');
|
||||
static $border_style_allowed = array('thin','medium','thick','dashDot','dashDotDot','dashed','dotted','double','hair','mediumDashDot','mediumDashDotDot','mediumDashed','slantDashDot');
|
||||
static $horizontal_allowed = array('general','left','right','justify','center');
|
||||
static $vertical_allowed = array('bottom','center','distributed','top');
|
||||
$default_font = array('size'=>'10','name'=>'Arial','family'=>'2');
|
||||
$fills = array('','');//2 placeholders for static xml later
|
||||
$fonts = array('','','','');//4 placeholders for static xml later
|
||||
$borders = array('');//1 placeholder for static xml later
|
||||
$style_indexes = array();
|
||||
foreach($this->cell_styles as $i=>$cell_style_string)
|
||||
{
|
||||
$semi_colon_pos = strpos($cell_style_string,";");
|
||||
$number_format_idx = substr($cell_style_string, 0, $semi_colon_pos);
|
||||
$style_json_string = substr($cell_style_string, $semi_colon_pos+1);
|
||||
$style = @json_decode($style_json_string, $as_assoc=true);
|
||||
|
||||
$style_indexes[$i] = array('num_fmt_idx'=>$number_format_idx);//initialize entry
|
||||
if (isset($style['border']) && is_string($style['border']))//border is a comma delimited str
|
||||
{
|
||||
$border_value['side'] = array_intersect(explode(",", $style['border']), $border_allowed);
|
||||
if (isset($style['border-style']) && in_array($style['border-style'],$border_style_allowed))
|
||||
{
|
||||
$border_value['style'] = $style['border-style'];
|
||||
}
|
||||
if (isset($style['border-color']) && is_string($style['border-color']) && $style['border-color'][0]=='#')
|
||||
{
|
||||
$v = substr($style['border-color'],1,6);
|
||||
$v = strlen($v)==3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v;// expand cf0 => ccff00
|
||||
$border_value['color'] = "FF".strtoupper($v);
|
||||
}
|
||||
$style_indexes[$i]['border_idx'] = self::add_to_list_get_index($borders, json_encode($border_value));
|
||||
}
|
||||
if (isset($style['fill']) && is_string($style['fill']) && $style['fill'][0]=='#')
|
||||
{
|
||||
$v = substr($style['fill'],1,6);
|
||||
$v = strlen($v)==3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v;// expand cf0 => ccff00
|
||||
$style_indexes[$i]['fill_idx'] = self::add_to_list_get_index($fills, "FF".strtoupper($v) );
|
||||
}
|
||||
if (isset($style['halign']) && in_array($style['halign'],$horizontal_allowed))
|
||||
{
|
||||
$style_indexes[$i]['alignment'] = true;
|
||||
$style_indexes[$i]['halign'] = $style['halign'];
|
||||
}
|
||||
if (isset($style['valign']) && in_array($style['valign'],$vertical_allowed))
|
||||
{
|
||||
$style_indexes[$i]['alignment'] = true;
|
||||
$style_indexes[$i]['valign'] = $style['valign'];
|
||||
}
|
||||
if (isset($style['wrap_text']))
|
||||
{
|
||||
$style_indexes[$i]['alignment'] = true;
|
||||
$style_indexes[$i]['wrap_text'] = (bool)$style['wrap_text'];
|
||||
}
|
||||
|
||||
$font = $default_font;
|
||||
if (isset($style['font-size']))
|
||||
{
|
||||
$font['size'] = floatval($style['font-size']);//floatval to allow "10.5" etc
|
||||
}
|
||||
if (isset($style['font']) && is_string($style['font']))
|
||||
{
|
||||
if ($style['font']=='Comic Sans MS') { $font['family']=4; }
|
||||
if ($style['font']=='Times New Roman') { $font['family']=1; }
|
||||
if ($style['font']=='Courier New') { $font['family']=3; }
|
||||
$font['name'] = strval($style['font']);
|
||||
}
|
||||
if (isset($style['font-style']) && is_string($style['font-style']))
|
||||
{
|
||||
if (strpos($style['font-style'], 'bold')!==false) { $font['bold'] = true; }
|
||||
if (strpos($style['font-style'], 'italic')!==false) { $font['italic'] = true; }
|
||||
if (strpos($style['font-style'], 'strike')!==false) { $font['strike'] = true; }
|
||||
if (strpos($style['font-style'], 'underline')!==false) { $font['underline'] = true; }
|
||||
}
|
||||
if (isset($style['color']) && is_string($style['color']) && $style['color'][0]=='#' )
|
||||
{
|
||||
$v = substr($style['color'],1,6);
|
||||
$v = strlen($v)==3 ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v;// expand cf0 => ccff00
|
||||
$font['color'] = "FF".strtoupper($v);
|
||||
}
|
||||
if ($font!=$default_font)
|
||||
{
|
||||
$style_indexes[$i]['font_idx'] = self::add_to_list_get_index($fonts, json_encode($font) );
|
||||
}
|
||||
}
|
||||
return array('fills'=>$fills,'fonts'=>$fonts,'borders'=>$borders,'styles'=>$style_indexes );
|
||||
}
|
||||
|
||||
protected function writeStylesXML()
|
||||
{
|
||||
$r = self::styleFontIndexes();
|
||||
$fills = $r['fills'];
|
||||
$fonts = $r['fonts'];
|
||||
$borders = $r['borders'];
|
||||
$style_indexes = $r['styles'];
|
||||
|
||||
$temporary_filename = $this->tempFilename();
|
||||
$file = new XLSXWriter_BuffererWriter($temporary_filename);
|
||||
$file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n");
|
||||
$file->write('<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">');
|
||||
$file->write('<numFmts count="'.count($this->number_formats).'">');
|
||||
foreach($this->number_formats as $i=>$v) {
|
||||
$file->write('<numFmt numFmtId="'.(164+$i).'" formatCode="'.self::xmlspecialchars($v).'" />');
|
||||
}
|
||||
//$file->write( '<numFmt formatCode="GENERAL" numFmtId="164"/>');
|
||||
//$file->write( '<numFmt formatCode="[$$-1009]#,##0.00;[RED]\-[$$-1009]#,##0.00" numFmtId="165"/>');
|
||||
//$file->write( '<numFmt formatCode="YYYY-MM-DD\ HH:MM:SS" numFmtId="166"/>');
|
||||
//$file->write( '<numFmt formatCode="YYYY-MM-DD" numFmtId="167"/>');
|
||||
$file->write('</numFmts>');
|
||||
|
||||
$file->write('<fonts count="'.(count($fonts)).'">');
|
||||
$file->write( '<font><name val="Arial"/><charset val="1"/><family val="2"/><sz val="10"/></font>');
|
||||
$file->write( '<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
|
||||
$file->write( '<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
|
||||
$file->write( '<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
|
||||
|
||||
foreach($fonts as $font) {
|
||||
if (!empty($font)) { //fonts have 4 empty placeholders in array to offset the 4 static xml entries above
|
||||
$f = json_decode($font,true);
|
||||
$file->write('<font>');
|
||||
$file->write( '<name val="'.htmlspecialchars($f['name']).'"/><charset val="1"/><family val="'.intval($f['family']).'"/>');
|
||||
$file->write( '<sz val="'.intval($f['size']).'"/>');
|
||||
if (!empty($f['color'])) { $file->write('<color rgb="'.strval($f['color']).'"/>'); }
|
||||
if (!empty($f['bold'])) { $file->write('<b val="true"/>'); }
|
||||
if (!empty($f['italic'])) { $file->write('<i val="true"/>'); }
|
||||
if (!empty($f['underline'])) { $file->write('<u val="single"/>'); }
|
||||
if (!empty($f['strike'])) { $file->write('<strike val="true"/>'); }
|
||||
$file->write('</font>');
|
||||
}
|
||||
}
|
||||
$file->write('</fonts>');
|
||||
|
||||
$file->write('<fills count="'.(count($fills)).'">');
|
||||
$file->write( '<fill><patternFill patternType="none"/></fill>');
|
||||
$file->write( '<fill><patternFill patternType="gray125"/></fill>');
|
||||
foreach($fills as $fill) {
|
||||
if (!empty($fill)) { //fills have 2 empty placeholders in array to offset the 2 static xml entries above
|
||||
$file->write('<fill><patternFill patternType="solid"><fgColor rgb="'.strval($fill).'"/><bgColor indexed="64"/></patternFill></fill>');
|
||||
}
|
||||
}
|
||||
$file->write('</fills>');
|
||||
|
||||
$file->write('<borders count="'.(count($borders)).'">');
|
||||
$file->write( '<border diagonalDown="false" diagonalUp="false"><left/><right/><top/><bottom/><diagonal/></border>');
|
||||
foreach($borders as $border) {
|
||||
if (!empty($border)) { //fonts have an empty placeholder in the array to offset the static xml entry above
|
||||
$pieces = json_decode($border,true);
|
||||
$border_style = !empty($pieces['style']) ? $pieces['style'] : 'hair';
|
||||
$border_color = !empty($pieces['color']) ? '<color rgb="'.strval($pieces['color']).'"/>' : '';
|
||||
$file->write('<border diagonalDown="false" diagonalUp="false">');
|
||||
foreach (array('left', 'right', 'top', 'bottom') as $side)
|
||||
{
|
||||
$show_side = in_array($side,$pieces['side']) ? true : false;
|
||||
$file->write($show_side ? "<$side style=\"$border_style\">$border_color</$side>" : "<$side/>");
|
||||
}
|
||||
$file->write( '<diagonal/>');
|
||||
$file->write('</border>');
|
||||
}
|
||||
}
|
||||
$file->write('</borders>');
|
||||
|
||||
$file->write('<cellStyleXfs count="20">');
|
||||
$file->write( '<xf applyAlignment="true" applyBorder="true" applyFont="true" applyProtection="true" borderId="0" fillId="0" fontId="0" numFmtId="164">');
|
||||
$file->write( '<alignment horizontal="general" indent="0" shrinkToFit="false" textRotation="0" vertical="bottom" wrapText="false"/>');
|
||||
$file->write( '<protection hidden="false" locked="true"/>');
|
||||
$file->write( '</xf>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="2" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="2" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="0"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="43"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="41"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="44"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="42"/>');
|
||||
$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="9"/>');
|
||||
$file->write('</cellStyleXfs>');
|
||||
|
||||
$file->write('<cellXfs count="'.(count($style_indexes)).'">');
|
||||
//$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="164" xfId="0"/>');
|
||||
//$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="165" xfId="0"/>');
|
||||
//$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="166" xfId="0"/>');
|
||||
//$file->write( '<xf applyAlignment="false" applyBorder="false" applyFont="false" applyProtection="false" borderId="0" fillId="0" fontId="0" numFmtId="167" xfId="0"/>');
|
||||
foreach($style_indexes as $v)
|
||||
{
|
||||
$applyAlignment = isset($v['alignment']) ? 'true' : 'false';
|
||||
$wrapText = !empty($v['wrap_text']) ? 'true' : 'false';
|
||||
$horizAlignment = isset($v['halign']) ? $v['halign'] : 'general';
|
||||
$vertAlignment = isset($v['valign']) ? $v['valign'] : 'bottom';
|
||||
$applyBorder = isset($v['border_idx']) ? 'true' : 'false';
|
||||
$applyFont = 'true';
|
||||
$borderIdx = isset($v['border_idx']) ? intval($v['border_idx']) : 0;
|
||||
$fillIdx = isset($v['fill_idx']) ? intval($v['fill_idx']) : 0;
|
||||
$fontIdx = isset($v['font_idx']) ? intval($v['font_idx']) : 0;
|
||||
//$file->write('<xf applyAlignment="'.$applyAlignment.'" applyBorder="'.$applyBorder.'" applyFont="'.$applyFont.'" applyProtection="false" borderId="'.($borderIdx).'" fillId="'.($fillIdx).'" fontId="'.($fontIdx).'" numFmtId="'.(164+$v['num_fmt_idx']).'" xfId="0"/>');
|
||||
$file->write('<xf applyAlignment="'.$applyAlignment.'" applyBorder="'.$applyBorder.'" applyFont="'.$applyFont.'" applyProtection="false" borderId="'.($borderIdx).'" fillId="'.($fillIdx).'" fontId="'.($fontIdx).'" numFmtId="'.(164+$v['num_fmt_idx']).'" xfId="0">');
|
||||
$file->write(' <alignment horizontal="'.$horizAlignment.'" vertical="'.$vertAlignment.'" textRotation="0" wrapText="'.$wrapText.'" indent="0" shrinkToFit="false"/>');
|
||||
$file->write(' <protection locked="true" hidden="false"/>');
|
||||
$file->write('</xf>');
|
||||
}
|
||||
$file->write('</cellXfs>');
|
||||
$file->write( '<cellStyles count="6">');
|
||||
$file->write( '<cellStyle builtinId="0" customBuiltin="false" name="Normal" xfId="0"/>');
|
||||
$file->write( '<cellStyle builtinId="3" customBuiltin="false" name="Comma" xfId="15"/>');
|
||||
$file->write( '<cellStyle builtinId="6" customBuiltin="false" name="Comma [0]" xfId="16"/>');
|
||||
$file->write( '<cellStyle builtinId="4" customBuiltin="false" name="Currency" xfId="17"/>');
|
||||
$file->write( '<cellStyle builtinId="7" customBuiltin="false" name="Currency [0]" xfId="18"/>');
|
||||
$file->write( '<cellStyle builtinId="5" customBuiltin="false" name="Percent" xfId="19"/>');
|
||||
$file->write( '</cellStyles>');
|
||||
$file->write('</styleSheet>');
|
||||
$file->close();
|
||||
return $temporary_filename;
|
||||
}
|
||||
|
||||
protected function buildAppXML()
|
||||
{
|
||||
$app_xml="";
|
||||
$app_xml.='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n";
|
||||
$app_xml.='<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">';
|
||||
$app_xml.='<TotalTime>0</TotalTime>';
|
||||
$app_xml.='<Company>'.self::xmlspecialchars($this->company).'</Company>';
|
||||
$app_xml.='</Properties>';
|
||||
return $app_xml;
|
||||
}
|
||||
|
||||
protected function buildCoreXML()
|
||||
{
|
||||
$core_xml="";
|
||||
$core_xml.='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n";
|
||||
$core_xml.='<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
|
||||
$core_xml.='<dcterms:created xsi:type="dcterms:W3CDTF">'.date("Y-m-d\TH:i:s.00\Z").'</dcterms:created>';//$date_time = '2014-10-25T15:54:37.00Z';
|
||||
$core_xml.='<dc:title>'.self::xmlspecialchars($this->title).'</dc:title>';
|
||||
$core_xml.='<dc:subject>'.self::xmlspecialchars($this->subject).'</dc:subject>';
|
||||
$core_xml.='<dc:creator>'.self::xmlspecialchars($this->author).'</dc:creator>';
|
||||
if (!empty($this->keywords)) {
|
||||
$core_xml.='<cp:keywords>'.self::xmlspecialchars(implode (", ", (array)$this->keywords)).'</cp:keywords>';
|
||||
}
|
||||
$core_xml.='<dc:description>'.self::xmlspecialchars($this->description).'</dc:description>';
|
||||
$core_xml.='<cp:revision>0</cp:revision>';
|
||||
$core_xml.='</cp:coreProperties>';
|
||||
return $core_xml;
|
||||
}
|
||||
|
||||
protected function buildRelationshipsXML()
|
||||
{
|
||||
$rels_xml="";
|
||||
$rels_xml.='<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$rels_xml.='<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';
|
||||
$rels_xml.='<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>';
|
||||
$rels_xml.='<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>';
|
||||
$rels_xml.='<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/>';
|
||||
$rels_xml.="\n";
|
||||
$rels_xml.='</Relationships>';
|
||||
return $rels_xml;
|
||||
}
|
||||
|
||||
protected function buildWorkbookXML()
|
||||
{
|
||||
$i=0;
|
||||
$workbook_xml="";
|
||||
$workbook_xml.='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n";
|
||||
$workbook_xml.='<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">';
|
||||
$workbook_xml.='<fileVersion appName="Calc"/><workbookPr backupFile="false" showObjects="all" date1904="false"/><workbookProtection/>';
|
||||
$workbook_xml.='<bookViews><workbookView activeTab="0" firstSheet="0" showHorizontalScroll="true" showSheetTabs="true" showVerticalScroll="true" tabRatio="212" windowHeight="8192" windowWidth="16384" xWindow="0" yWindow="0"/></bookViews>';
|
||||
$workbook_xml.='<sheets>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
$sheetname = self::sanitize_sheetname($sheet->sheetname);
|
||||
$workbook_xml.='<sheet name="'.self::xmlspecialchars($sheetname).'" sheetId="'.($i+1).'" state="visible" r:id="rId'.($i+2).'"/>';
|
||||
$i++;
|
||||
}
|
||||
$workbook_xml.='</sheets>';
|
||||
$workbook_xml.='<definedNames>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
if ($sheet->auto_filter) {
|
||||
$sheetname = self::sanitize_sheetname($sheet->sheetname);
|
||||
$workbook_xml.='<definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">\''.self::xmlspecialchars($sheetname).'\'!$A$1:' . self::xlsCell($sheet->row_count - 1, count($sheet->columns) - 1, true) . '</definedName>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$workbook_xml.='</definedNames>';
|
||||
$workbook_xml.='<calcPr iterateCount="100" refMode="A1" iterate="false" iterateDelta="0.001"/></workbook>';
|
||||
return $workbook_xml;
|
||||
}
|
||||
|
||||
protected function buildWorkbookRelsXML()
|
||||
{
|
||||
$i=0;
|
||||
$wkbkrels_xml="";
|
||||
$wkbkrels_xml.='<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$wkbkrels_xml.='<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';
|
||||
$wkbkrels_xml.='<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
$wkbkrels_xml.='<Relationship Id="rId'.($i+2).'" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/'.($sheet->xmlname).'"/>';
|
||||
$i++;
|
||||
}
|
||||
$wkbkrels_xml.="\n";
|
||||
$wkbkrels_xml.='</Relationships>';
|
||||
return $wkbkrels_xml;
|
||||
}
|
||||
|
||||
protected function buildContentTypesXML()
|
||||
{
|
||||
$content_types_xml="";
|
||||
$content_types_xml.='<?xml version="1.0" encoding="UTF-8"?>'."\n";
|
||||
$content_types_xml.='<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
||||
$content_types_xml.='<Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/xl/_rels/workbook.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>';
|
||||
foreach($this->sheets as $sheet_name=>$sheet) {
|
||||
$content_types_xml.='<Override PartName="/xl/worksheets/'.($sheet->xmlname).'" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>';
|
||||
}
|
||||
$content_types_xml.='<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>';
|
||||
$content_types_xml.='<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>';
|
||||
$content_types_xml.="\n";
|
||||
$content_types_xml.='</Types>';
|
||||
return $content_types_xml;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/*
|
||||
* @param $row_number int, zero based
|
||||
* @param $column_number int, zero based
|
||||
* @param $absolute bool
|
||||
* @return Cell label/coordinates, ex: A1, C3, AA42 (or if $absolute==true: $A$1, $C$3, $AA$42)
|
||||
* */
|
||||
public static function xlsCell($row_number, $column_number, $absolute=false)
|
||||
{
|
||||
$n = $column_number;
|
||||
for($r = ""; $n >= 0; $n = intval($n / 26) - 1) {
|
||||
$r = chr($n%26 + 0x41) . $r;
|
||||
}
|
||||
if ($absolute) {
|
||||
return '$' . $r . '$' . ($row_number+1);
|
||||
}
|
||||
return $r . ($row_number+1);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function log($string)
|
||||
{
|
||||
//file_put_contents("php://stderr", date("Y-m-d H:i:s:").rtrim(is_array($string) ? json_encode($string) : $string)."\n");
|
||||
error_log(date("Y-m-d H:i:s:").rtrim(is_array($string) ? json_encode($string) : $string)."\n");
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function sanitize_filename($filename) //http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx
|
||||
{
|
||||
$nonprinting = array_map('chr', range(0,31));
|
||||
$invalid_chars = array('<', '>', '?', '"', ':', '|', '\\', '/', '*', '&');
|
||||
$all_invalids = array_merge($nonprinting,$invalid_chars);
|
||||
return str_replace($all_invalids, "", $filename);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function sanitize_sheetname($sheetname)
|
||||
{
|
||||
static $badchars = '\\/?*:[]';
|
||||
static $goodchars = ' ';
|
||||
$sheetname = strtr($sheetname, $badchars, $goodchars);
|
||||
$sheetname = function_exists('mb_substr') ? mb_substr($sheetname, 0, 31) : substr($sheetname, 0, 31);
|
||||
$sheetname = trim(trim(trim($sheetname),"'"));//trim before and after trimming single quotes
|
||||
return !empty($sheetname) ? $sheetname : 'Sheet'.((rand()%900)+100);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function xmlspecialchars($val)
|
||||
{
|
||||
//note, badchars does not include \t\n\r (\x09\x0a\x0d)
|
||||
static $badchars = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f";
|
||||
static $goodchars = " ";
|
||||
return strtr(htmlspecialchars($val, ENT_QUOTES | ENT_XML1), $badchars, $goodchars);//strtr appears to be faster than str_replace
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function array_first_key(array $arr)
|
||||
{
|
||||
reset($arr);
|
||||
$first_key = key($arr);
|
||||
return $first_key;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
private static function determineNumberFormatType($num_format)
|
||||
{
|
||||
$num_format = preg_replace("/\[(Black|Blue|Cyan|Green|Magenta|Red|White|Yellow)\]/i", "", $num_format);
|
||||
if ($num_format=='GENERAL') return 'n_auto';
|
||||
if ($num_format=='@') return 'n_string';
|
||||
if ($num_format=='0') return 'n_numeric';
|
||||
if (preg_match('/[H]{1,2}:[M]{1,2}(?![^"]*+")/i', $num_format)) return 'n_datetime';
|
||||
if (preg_match('/[M]{1,2}:[S]{1,2}(?![^"]*+")/i', $num_format)) return 'n_datetime';
|
||||
if (preg_match('/[Y]{2,4}(?![^"]*+")/i', $num_format)) return 'n_date';
|
||||
if (preg_match('/[D]{1,2}(?![^"]*+")/i', $num_format)) return 'n_date';
|
||||
if (preg_match('/[M]{1,2}(?![^"]*+")/i', $num_format)) return 'n_date';
|
||||
if (preg_match('/$(?![^"]*+")/', $num_format)) return 'n_numeric';
|
||||
if (preg_match('/%(?![^"]*+")/', $num_format)) return 'n_numeric';
|
||||
if (preg_match('/0(?![^"]*+")/', $num_format)) return 'n_numeric';
|
||||
return 'n_auto';
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
private static function numberFormatStandardized($num_format)
|
||||
{
|
||||
if ($num_format=='money') { $num_format='dollar'; }
|
||||
if ($num_format=='number') { $num_format='integer'; }
|
||||
|
||||
if ($num_format=='string') $num_format='@';
|
||||
else if ($num_format=='integer') $num_format='0';
|
||||
else if ($num_format=='date') $num_format='YYYY-MM-DD';
|
||||
else if ($num_format=='datetime') $num_format='YYYY-MM-DD HH:MM:SS';
|
||||
else if ($num_format=='time') $num_format='HH:MM:SS';
|
||||
else if ($num_format=='price') $num_format='#,##0.00';
|
||||
else if ($num_format=='dollar') $num_format='[$$-1009]#,##0.00;[RED]-[$$-1009]#,##0.00';
|
||||
else if ($num_format=='euro') $num_format='#,##0.00 [$€-407];[RED]-#,##0.00 [$€-407]';
|
||||
$ignore_until='';
|
||||
$escaped = '';
|
||||
for($i=0,$ix=strlen($num_format); $i<$ix; $i++)
|
||||
{
|
||||
$c = $num_format[$i];
|
||||
if ($ignore_until=='' && $c=='[')
|
||||
$ignore_until=']';
|
||||
else if ($ignore_until=='' && $c=='"')
|
||||
$ignore_until='"';
|
||||
else if ($ignore_until==$c)
|
||||
$ignore_until='';
|
||||
if ($ignore_until=='' && ($c==' ' || $c=='-' || $c=='(' || $c==')') && ($i==0 || $num_format[$i-1]!='_'))
|
||||
$escaped.= "\\".$c;
|
||||
else
|
||||
$escaped.= $c;
|
||||
}
|
||||
return $escaped;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function add_to_list_get_index(&$haystack, $needle)
|
||||
{
|
||||
$existing_idx = array_search($needle, $haystack, $strict=true);
|
||||
if ($existing_idx===false)
|
||||
{
|
||||
$existing_idx = count($haystack);
|
||||
$haystack[] = $needle;
|
||||
}
|
||||
return $existing_idx;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
public static function convert_date_time($date_input) //thanks to Excel::Writer::XLSX::Worksheet.pm (perl)
|
||||
{
|
||||
$days = 0; # Number of days since epoch
|
||||
$seconds = 0; # Time expressed as fraction of 24h hours in seconds
|
||||
$year=$month=$day=0;
|
||||
$hour=$min =$sec=0;
|
||||
|
||||
$date_time = $date_input;
|
||||
if (preg_match("/(\d{4})\-(\d{2})\-(\d{2})/", $date_time, $matches))
|
||||
{
|
||||
list($junk,$year,$month,$day) = $matches;
|
||||
}
|
||||
if (preg_match("/(\d+):(\d{2}):(\d{2})/", $date_time, $matches))
|
||||
{
|
||||
list($junk,$hour,$min,$sec) = $matches;
|
||||
$seconds = ( $hour * 60 * 60 + $min * 60 + $sec ) / ( 24 * 60 * 60 );
|
||||
}
|
||||
|
||||
//using 1900 as epoch, not 1904, ignoring 1904 special case
|
||||
|
||||
# Special cases for Excel.
|
||||
if ("$year-$month-$day"=='1899-12-31') return $seconds ; # Excel 1900 epoch
|
||||
if ("$year-$month-$day"=='1900-01-00') return $seconds ; # Excel 1900 epoch
|
||||
if ("$year-$month-$day"=='1900-02-29') return 60 + $seconds ; # Excel false leapday
|
||||
|
||||
# We calculate the date by calculating the number of days since the epoch
|
||||
# and adjust for the number of leap days. We calculate the number of leap
|
||||
# days by normalising the year in relation to the epoch. Thus the year 2000
|
||||
# becomes 100 for 4 and 100 year leapdays and 400 for 400 year leapdays.
|
||||
$epoch = 1900;
|
||||
$offset = 0;
|
||||
$norm = 300;
|
||||
$range = $year - $epoch;
|
||||
|
||||
# Set month days and check for leap year.
|
||||
$leap = (($year % 400 == 0) || (($year % 4 == 0) && ($year % 100)) ) ? 1 : 0;
|
||||
$mdays = array( 31, ($leap ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
|
||||
|
||||
# Some boundary checks
|
||||
if ($year!=0 || $month !=0 || $day!=0)
|
||||
{
|
||||
if($year < $epoch || $year > 9999) return 0;
|
||||
if($month < 1 || $month > 12) return 0;
|
||||
if($day < 1 || $day > $mdays[ $month - 1 ]) return 0;
|
||||
}
|
||||
|
||||
# Accumulate the number of days since the epoch.
|
||||
$days = $day; # Add days for current month
|
||||
$days += array_sum( array_slice($mdays, 0, $month-1 ) ); # Add days for past months
|
||||
$days += $range * 365; # Add days for past years
|
||||
$days += intval( ( $range ) / 4 ); # Add leapdays
|
||||
$days -= intval( ( $range + $offset ) / 100 ); # Subtract 100 year leapdays
|
||||
$days += intval( ( $range + $offset + $norm ) / 400 ); # Add 400 year leapdays
|
||||
$days -= $leap; # Already counted above
|
||||
|
||||
# Adjust for Excel erroneously treating 1900 as a leap year.
|
||||
if ($days > 59) { $days++;}
|
||||
|
||||
return $days + $seconds;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
}
|
||||
|
||||
class XLSXWriter_BuffererWriter
|
||||
{
|
||||
protected $fd=null;
|
||||
protected $buffer='';
|
||||
protected $check_utf8=false;
|
||||
|
||||
public function __construct($filename, $fd_fopen_flags='w', $check_utf8=false)
|
||||
{
|
||||
$this->check_utf8 = $check_utf8;
|
||||
$this->fd = fopen($filename, $fd_fopen_flags);
|
||||
if ($this->fd===false) {
|
||||
XLSXWriter::log("Unable to open $filename for writing.");
|
||||
}
|
||||
}
|
||||
|
||||
public function write($string)
|
||||
{
|
||||
$this->buffer.=$string;
|
||||
if (isset($this->buffer[8191])) {
|
||||
$this->purge();
|
||||
}
|
||||
}
|
||||
|
||||
protected function purge()
|
||||
{
|
||||
if ($this->fd) {
|
||||
if ($this->check_utf8 && !self::isValidUTF8($this->buffer)) {
|
||||
XLSXWriter::log("Error, invalid UTF8 encoding detected.");
|
||||
$this->check_utf8 = false;
|
||||
}
|
||||
fwrite($this->fd, $this->buffer);
|
||||
$this->buffer='';
|
||||
}
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
$this->purge();
|
||||
if ($this->fd) {
|
||||
fclose($this->fd);
|
||||
$this->fd=null;
|
||||
}
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
$this->close();
|
||||
}
|
||||
|
||||
public function ftell()
|
||||
{
|
||||
if ($this->fd) {
|
||||
$this->purge();
|
||||
return ftell($this->fd);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function fseek($pos)
|
||||
{
|
||||
if ($this->fd) {
|
||||
$this->purge();
|
||||
return fseek($this->fd, $pos);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
protected static function isValidUTF8($string)
|
||||
{
|
||||
if (function_exists('mb_check_encoding'))
|
||||
{
|
||||
return mb_check_encoding($string, 'UTF-8') ? true : false;
|
||||
}
|
||||
return preg_match("//u", $string) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// vim: set filetype=php expandtab tabstop=4 shiftwidth=4 autoindent smartindent:
|
1
index.php
Normal file
1
index.php
Normal file
|
@ -0,0 +1 @@
|
|||
<?php // Silence is golden
|
BIN
languages/avadaforms-excel-export-it_IT.mo
Normal file
BIN
languages/avadaforms-excel-export-it_IT.mo
Normal file
Binary file not shown.
67
languages/avadaforms-excel-export-it_IT.po
Normal file
67
languages/avadaforms-excel-export-it_IT.po
Normal file
|
@ -0,0 +1,67 @@
|
|||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Avada Forms to Excel / CSV\n"
|
||||
"POT-Creation-Date: 2021-01-22 14:18+0100\n"
|
||||
"PO-Revision-Date: 2021-01-22 14:19+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: it_IT\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"X-Generator: Poedit 2.4.2\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
|
||||
"X-Poedit-WPHeader: avadaforms-excel-export.php\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
|
||||
"_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
"X-Poedit-SearchPathExcluded-0: *.min.js\n"
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:226
|
||||
msgid "Export options"
|
||||
msgstr "Opzioni di esportazione"
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:232
|
||||
msgid "Export as"
|
||||
msgstr "Esporta come"
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:236
|
||||
msgid "Select"
|
||||
msgstr "Seleziona"
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:253
|
||||
msgid "Export"
|
||||
msgstr "Esporta"
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:266
|
||||
msgid "Avada Forms"
|
||||
msgstr "Form di Avada"
|
||||
|
||||
#: includes/class-avadaforms-excel-export-activator.php:40
|
||||
msgid "Looks like Avada or Fusion Forms are not installed."
|
||||
msgstr "Sembra che Avada o Fusion Forms non siano installati."
|
||||
|
||||
#: includes/class-avadaforms-excel-export-activator.php:41
|
||||
msgid "Avada Forms to Excel / CSV was not activated."
|
||||
msgstr "Avada Forms to Excel / CSV non è stato attivato."
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Avada Forms to Excel / CSV"
|
||||
msgstr "Avada Forms to Excel / CSV"
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "https://www.dueclic.com"
|
||||
msgstr "https://www.dueclic.com"
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid "Easily export your Avada Forms data to Excel / CSV"
|
||||
msgstr "Esporta facilmente i tuoi form di Avada in Excel / CSV"
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "dueclic"
|
||||
msgstr "dueclic"
|
67
languages/avadaforms-excel-export.pot
Normal file
67
languages/avadaforms-excel-export.pot
Normal file
|
@ -0,0 +1,67 @@
|
|||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
||||
"Project-Id-Version: Avada Forms to Excel / CSV\n"
|
||||
"POT-Creation-Date: 2021-01-22 14:18+0100\n"
|
||||
"PO-Revision-Date: 2021-01-22 13:59+0100\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 2.4.2\n"
|
||||
"X-Poedit-Basepath: ..\n"
|
||||
"X-Poedit-Flags-xgettext: --add-comments=translators:\n"
|
||||
"X-Poedit-WPHeader: avadaforms-excel-export.php\n"
|
||||
"X-Poedit-SourceCharset: UTF-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
|
||||
"esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;"
|
||||
"_n_noop:1,2;_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
"X-Poedit-SearchPathExcluded-0: *.min.js\n"
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:226
|
||||
msgid "Export options"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:232
|
||||
msgid "Export as"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:236
|
||||
msgid "Select"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:253
|
||||
msgid "Export"
|
||||
msgstr ""
|
||||
|
||||
#: admin/class-avadaforms-excel-export-admin.php:266
|
||||
msgid "Avada Forms"
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-avadaforms-excel-export-activator.php:40
|
||||
msgid "Looks like Avada or Fusion Forms are not installed."
|
||||
msgstr ""
|
||||
|
||||
#: includes/class-avadaforms-excel-export-activator.php:41
|
||||
msgid "Avada Forms to Excel / CSV was not activated."
|
||||
msgstr ""
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Avada Forms to Excel / CSV"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "https://www.dueclic.com"
|
||||
msgstr ""
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid "Easily export your Avada Forms data to Excel / CSV"
|
||||
msgstr ""
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "dueclic"
|
||||
msgstr ""
|
103
public/class-avadaforms-excel-export-public.php
Normal file
103
public/class-avadaforms-excel-export-public.php
Normal file
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the plugin.
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/public
|
||||
*/
|
||||
|
||||
/**
|
||||
* The public-facing functionality of the plugin.
|
||||
*
|
||||
* Defines the plugin name, version, and two examples hooks for how to
|
||||
* enqueue the public-facing stylesheet and JavaScript.
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/public
|
||||
* @author dueclic <info@dueclic.com>
|
||||
*/
|
||||
class Avadaforms_Excel_Export_Public {
|
||||
|
||||
/**
|
||||
* The ID of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @var string $plugin_name The ID of this plugin.
|
||||
*/
|
||||
private $plugin_name;
|
||||
|
||||
/**
|
||||
* The version of this plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @var string $version The current version of this plugin.
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* Initialize the class and set its properties.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $plugin_name The name of the plugin.
|
||||
* @param string $version The version of this plugin.
|
||||
*/
|
||||
public function __construct( $plugin_name, $version ) {
|
||||
|
||||
$this->plugin_name = $plugin_name;
|
||||
$this->version = $version;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets for the public-facing side of the site.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function enqueue_styles() {
|
||||
|
||||
/**
|
||||
* This function is provided for demonstration purposes only.
|
||||
*
|
||||
* An instance of this class should be passed to the run() function
|
||||
* defined in Avadaforms_Excel_Export_Loader as all of the hooks are defined
|
||||
* in that particular class.
|
||||
*
|
||||
* The Avadaforms_Excel_Export_Loader will then create the relationship
|
||||
* between the defined hooks and the functions defined in this
|
||||
* class.
|
||||
*/
|
||||
|
||||
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/avadaforms-excel-export-public.css', array(), $this->version, 'all' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the JavaScript for the public-facing side of the site.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
|
||||
/**
|
||||
* This function is provided for demonstration purposes only.
|
||||
*
|
||||
* An instance of this class should be passed to the run() function
|
||||
* defined in Avadaforms_Excel_Export_Loader as all of the hooks are defined
|
||||
* in that particular class.
|
||||
*
|
||||
* The Avadaforms_Excel_Export_Loader will then create the relationship
|
||||
* between the defined hooks and the functions defined in this
|
||||
* class.
|
||||
*/
|
||||
|
||||
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/avadaforms-excel-export-public.js', array( 'jquery' ), $this->version, false );
|
||||
|
||||
}
|
||||
|
||||
}
|
4
public/css/avadaforms-excel-export-public.css
Normal file
4
public/css/avadaforms-excel-export-public.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* All of the CSS for your public-facing functionality should be
|
||||
* included in this file.
|
||||
*/
|
1
public/index.php
Normal file
1
public/index.php
Normal file
|
@ -0,0 +1 @@
|
|||
<?php // Silence is golden
|
32
public/js/avadaforms-excel-export-public.js
Normal file
32
public/js/avadaforms-excel-export-public.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
(function( $ ) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* All of the code for your public-facing JavaScript source
|
||||
* should reside in this file.
|
||||
*
|
||||
* Note: It has been assumed you will write jQuery code here, so the
|
||||
* $ function reference has been prepared for usage within the scope
|
||||
* of this function.
|
||||
*
|
||||
* This enables you to define handlers, for when the DOM is ready:
|
||||
*
|
||||
* $(function() {
|
||||
*
|
||||
* });
|
||||
*
|
||||
* When the window is loaded:
|
||||
*
|
||||
* $( window ).load(function() {
|
||||
*
|
||||
* });
|
||||
*
|
||||
* ...and/or other possibilities.
|
||||
*
|
||||
* Ideally, it is not considered best practise to attach more than a
|
||||
* single DOM-ready or window-load handler for a particular page.
|
||||
* Although scripts in the WordPress core, Plugins and Themes may be
|
||||
* practising this, we should strive to set a better example in our own work.
|
||||
*/
|
||||
|
||||
})( jQuery );
|
16
public/partials/avadaforms-excel-export-public-display.php
Normal file
16
public/partials/avadaforms-excel-export-public-display.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Provide a public-facing view for the plugin
|
||||
*
|
||||
* This file is used to markup the public-facing aspects of the plugin.
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
* @subpackage Avadaforms_Excel_Export/public/partials
|
||||
*/
|
||||
?>
|
||||
|
||||
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
|
31
uninstall.php
Normal file
31
uninstall.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Fired when the plugin is uninstalled.
|
||||
*
|
||||
* When populating this file, consider the following flow
|
||||
* of control:
|
||||
*
|
||||
* - This method should be static
|
||||
* - Check if the $_REQUEST content actually is the plugin name
|
||||
* - Run an admin referrer check to make sure it goes through authentication
|
||||
* - Verify the output of $_GET makes sense
|
||||
* - Repeat with other user roles. Best directly by using the links/query string parameters.
|
||||
* - Repeat things for multisite. Once for a single site in the network, once sitewide.
|
||||
*
|
||||
* This file may be updated more in future version of the Boilerplate; however, this is the
|
||||
* general skeleton and outline for how the file should work.
|
||||
*
|
||||
* For more information, see the following discussion:
|
||||
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
|
||||
*
|
||||
* @link https://www.dueclic.com
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Avadaforms_Excel_Export
|
||||
*/
|
||||
|
||||
// If uninstall not called from WordPress, then exit.
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue