PageRenderTime 53ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/www/wp-content/plugins/contact-form-7-to-database-extension/ExportToGoogleLiveData.php

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