-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExportToGoogleLiveData.php
executable file
·192 lines (174 loc) · 9.65 KB
/
ExportToGoogleLiveData.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/*
"Contact Form to Database" Copyright (C) 2011-2014 Michael Simpson (email : [email protected])
This file is part of Contact Form to Database.
Contact Form to Database 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 3 of the License, or
(at your option) any later version.
Contact Form to Database 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 Contact Form to Database.
If not, see <http://www.gnu.org/licenses/>.
*/
require_once('CF7DBPlugin.php');
require_once('CFDBExport.php');
include_once('CFDBDie.php');
class ExportToGoogleLiveData implements CFDBExport {
public function export($formName, $options = null) {
$plugin = new CF7DBPlugin();
if (!$plugin->canUserDoRoleOption('CanSeeSubmitData')) {
CFDBDie::wp_die(__('You do not have sufficient permissions to access this page.', 'contact-form-7-to-database-extension'));
}
header('Expires: 0');
header('Cache-Control: no-store, no-cache, must-revalidate');
$pluginUrlDir = $plugin->getPluginDirUrl();
$scriptLink = $pluginUrlDir . 'CFDBGoogleSSLiveData.php';
$imageUrlDir = $pluginUrlDir . "help";
$siteUrl = get_option('home');
$userName = is_user_logged_in() ? wp_get_current_user()->user_login : 'user';
ob_start();
?>
<style type="text/css">
*.popup-trigger {
position: relative;
z-index: 0;
}
*.popup-trigger:hover {
background-color: transparent;
z-index: 50;
}
*.popup-content {
position: absolute!important;
background-color: #ffffff;
padding: 5px;
border: 2px gray;
visibility: hidden!important;
color: black;
text-decoration: none;
min-width:400px;
max-width:600px;
overflow: auto;
}
*.popup-trigger:hover *.popup-content {
visibility: visible!important;
top: 50px!important;
left: 50px!important;
}
</style>
<?php _e('Setting up a Google Spreadsheet to pull in data from WordPress requires these manual steps:', 'contact-form-7-to-database-extension'); ?>
<table cellspacing="15px" cellpadding="15px">
<tbody>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php echo $imageUrlDir ?>/GoogleNewSS.png">
<img src="<?php echo $imageUrlDir ?>/GoogleNewSS.png" alt="Create a new spreadsheet" height="100px" width="61px"/>
<div class="popup-content">
<img src="<?php echo $imageUrlDir ?>/GoogleNewSS.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
</div>
</a>
</div>
</td>
<td><p><?php _e('Log into Google Docs and create a new Google Spreadsheet', 'contact-form-7-to-database-extension'); ?></p></td>
</tr>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php echo $imageUrlDir ?>/GoogleOpenScriptEditor.png">
<img src="<?php echo $imageUrlDir ?>/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet" height="69px" width="100px"/>
<div class="popup-content">
<img src="<?php echo $imageUrlDir ?>/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
</div>
</a>
</div>
</td>
<td><p><?php _e('Go to <strong>Tools</strong> menu -> <strong>Script Editor...', 'contact-form-7-to-database-extension'); ?></p></td>
</tr>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php echo $imageUrlDir ?>/GoogleChooseSpreadsheet.png">
<img src="<?php echo $imageUrlDir ?>/GoogleChooseSpreadsheet.png" alt="Choose Spreadsheet" height="69px" width="100px"/>
<div class="popup-content">
<img src="<?php echo $imageUrlDir ?>/GoogleChooseSpreadsheet.png" alt="GoogleChooseSpreadsheet Spreadsheet" height="75%" width="75%"/>
</div>
</a>
</div>
</td>
<td><p><?php _e('Choose <strong>Spreadsheet</strong>', 'contact-form-7-to-database-extension'); ?></p></td>
</tr>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php echo $imageUrlDir ?>/GooglePasteScriptEditor.png">
<img src="<?php echo $imageUrlDir ?>/GooglePasteScriptEditor.png" alt="Paste script text" height="68px" width="100px"/>
<div class="popup-content">
<img src="<?php echo $imageUrlDir ?>/GooglePasteScriptEditor.png" alt="Paste script text" height="75%" width="75%"/>
</div>
</a>
</div>
</td>
<td>
<p><?php _e('Delete any text that is already there', 'contact-form-7-to-database-extension'); ?></p>
<p><?php _e('<strong>Copy</strong> the text from ', 'contact-form-7-to-database-extension'); ?>
<a target="_gscript" href="<?php echo($scriptLink) ?>"><?php _e('THIS SCRIPT FILE', 'contact-form-7-to-database-extension'); ?></a>
<?php _e('and <strong>paste</strong> it into the Google script editor', 'contact-form-7-to-database-extension'); ?></p>
</td>
</tr>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php echo $imageUrlDir ?>/GoogleSaveScriptEditor.png">
<img src="<?php echo $imageUrlDir ?>/GoogleSaveScriptEditor.png" alt="Create a new spreadsheet" height="100px" width="83px"/>
<div class="popup-content">
<img src="<?php echo $imageUrlDir ?>/GoogleSaveScriptEditor.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
</div>
</a>
</div>
</td>
<td>
<p><?php _e('<strong>Save</strong> the script', 'contact-form-7-to-database-extension'); ?></p>
</td>
</tr>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php echo $imageUrlDir ?>/GoogleEnterFormula.png">
<img src="<?php echo $imageUrlDir ?>/GoogleEnterFormula.png" alt="Create a new spreadsheet" height="43px" width="100px"/>
<div class="popup-content">
<img src="<?php echo $imageUrlDir ?>/GoogleEnterFormula.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
</div>
</a>
</div>
</td>
<td>
<p><?php _e('Click on a cell A1 in the Spreadsheet (or any cell)', 'contact-form-7-to-database-extension'); ?>
<br/><?php _e('Enter in the cell the formula:', 'contact-form-7-to-database-extension'); ?>
<br/><span style="background-color: yellow"><code><?php echo("=cfdbdata(\"$siteUrl\", \"$formName\", \"$userName\", \"<password>\")") ?></code></span>
<br/><?php _e('Replace <strong><password></strong> with your <em>WordPress</em> password', 'contact-form-7-to-database-extension'); ?>
</p>
<?php
$scBuilderPageUrl = $siteUrl . '/wp-admin/admin.php?page=CF7DBPluginShortCodeBuilder&enc=GLD&form=' . urlencode($formName);
?>
<p>
<a href="<?php echo $scBuilderPageUrl ?>" target="sc"><?php _e('Customize the output by creating a Google Spreadsheet Function call with additional options', 'contact-form-7-to-database-extension'); ?></a>
</p>
</td>
</tr>
</tbody>
</table>
<span style="color:red; font-weight:bold;">
WARNING: since you are putting your login information into the Google Spreadsheet, be sure not to share
the spreadsheet with others.</span>
<?php
$html = ob_get_contents();
ob_end_clean();
CFDBDie::wp_die($html,
__('How to Set up Google Spreadsheet to pull data from WordPress', 'contact-form-7-to-database-extension'),
array('response' => 200, 'back_link' => true));
}
}