CFDBViewWhatsInDB

The Contact Form DB CFDBViewWhatsInDB class.

Defined (1)

The class is defined in the following location(s).

/CFDBViewWhatsInDB.php  
  1. class CFDBViewWhatsInDB extends CFDBView { 
  2.  
  3. function display(&$plugin) { 
  4. if ($plugin == null) { 
  5. $plugin = new CF7DBPlugin; 
  6. $canEdit = $plugin->canUserDoRoleOption('CanChangeSubmitData'); 
  7. $this->pageHeader($plugin); 
  8.  
  9. global $wpdb; 
  10. $tableName = $plugin->getSubmitsTableName(); 
  11. $useDataTables = $plugin->getOption('UseDataTablesJS', 'true') == 'true'; 
  12. $tableHtmlId = 'cf2dbtable'; 
  13.  
  14. // Identify which forms have data in the database 
  15. $formsList = $plugin->getForms(); 
  16. if (count($formsList) == 0) { 
  17. echo htmlspecialchars(__('No form submissions in the database', 'contact-form-7-to-database-extension')); 
  18. return; 
  19. $page = 1; 
  20. if (isset($_REQUEST['dbpage'])) { 
  21. $page = $this->getRequestParam('dbpage'); 
  22. $currSelection = null; 
  23. if (isset($_REQUEST['form_name'])) { 
  24. $currSelection = $this->getRequestParam('form_name'); 
  25. else if (isset($_REQUEST['form'])) { 
  26. $currSelection = $this->getRequestParam('form'); 
  27.  
  28. if ($currSelection) { 
  29. $currSelection = stripslashes($currSelection); 
  30. $currSelection = html_entity_decode($currSelection); 
  31.  
  32. $currSelectionEscaped = htmlentities($currSelection, null, 'UTF-8'); 
  33. // If there is only one form in the DB, select that by default 
  34. if (!$currSelection && count($formsList) == 1) { 
  35. $currSelection = $formsList[0]; 
  36. // Bug fix: Need to set this so the Editor plugin can reference it 
  37. $_REQUEST['form_name'] = $formsList[0]; 
  38. if ($currSelection) { 
  39. // Check for delete operation 
  40. if (isset($_POST['delete']) && 
  41. $canEdit && 
  42. wp_verify_nonce($_REQUEST['_wpnonce'])) { 
  43. if (isset($_POST['submit_time'])) { 
  44. $submitTime = $_POST['submit_time']; 
  45. $wpdb->query( 
  46. $wpdb->prepare( 
  47. "delete from `$tableName` where `form_name` = '%s' and `submit_time` = %F",  
  48. $currSelection, $submitTime)); 
  49. else if (isset($_POST['all'])) { 
  50. $wpdb->query( 
  51. $wpdb->prepare( 
  52. "delete from `$tableName` where `form_name` = '%s'", $currSelection)); 
  53. else { 
  54. foreach ($_POST as $name => $value) { // checkboxes 
  55. if ($value == 'row') { 
  56. // Dots and spaces in variable names are converted to underscores. For example <input name="a.b" /> becomes $_REQUEST["a_b"]. 
  57. // http://www.php.net/manual/en/language.variables.external.php 
  58. // We are expecting a time value like '1300728460.6626' but will instead get '1300728460_6626' 
  59. // so we need to put the '.' back in before going to the DB. 
  60. $name = str_replace('_', '.', $name); 
  61. $wpdb->query( 
  62. $wpdb->prepare( 
  63. "delete from `$tableName` where `form_name` = '%s' and `submit_time` = %F",  
  64. $currSelection, $name)); 
  65. else if (isset($_POST['delete_wpcf7']) && 
  66. $canEdit && 
  67. wp_verify_nonce($_REQUEST['_wpnonce'])) { 
  68. $plugin->delete_wpcf7_fields($currSelection); 
  69. $plugin->add_wpcf7_noSaveFields(); 
  70. // Form selection drop-down list 
  71. $pluginDirUrl = $plugin->getPluginDirUrl(); 
  72.  
  73. ?> 
  74. <table width="100%" cellspacing="20"> 
  75. <tr> 
  76. <td align="left" valign="top"> 
  77. <form method="get" action="" name="displayform" id="displayform"> 
  78. <input type="hidden" name="page" value="<?php echo htmlspecialchars($this->getRequestParam('page')) ?>"/> 
  79. <select name="form_name" id="form_name" onchange="this.form.submit();"> 
  80. <option value=""><?php echo htmlspecialchars(__('* Select a form *', 'contact-form-7-to-database-extension')); ?></option> 
  81. <?php foreach ($formsList as $formName) { 
  82. $selected = ($formName == $currSelection) ? "selected" : ""; 
  83. $formNameEscaped = htmlentities($formName, null, 'UTF-8'); 
  84. ?> 
  85. <option value="<?php echo $formNameEscaped ?>" <?php echo $selected ?>><?php echo $formNameEscaped ?></option> 
  86. <?php } ?> 
  87. </select> 
  88. </form> 
  89. </td> 
  90. <td align="center" valign="top"> 
  91. <?php if ($currSelection) { ?> 
  92. <script type="text/javascript" language="Javascript"> 
  93. function changeDbPage(page) { 
  94. var newdiv = document.createElement('div'); 
  95. newdiv.innerHTML = "<input id='dbpage' name='dbpage' type='hidden' value='" + page + "'>"; 
  96. var dispForm = document.forms['displayform']; 
  97. dispForm.appendChild(newdiv); 
  98. dispForm.submit(); 
  99. function getSearchFieldValue() { 
  100. var searchVal = ''; 
  101. if (typeof jQuery == 'function') { 
  102. try { 
  103. searchVal = jQuery('#<?php echo $tableHtmlId;?>_filter input').val(); 
  104. catch (e) { 
  105. return searchVal; 
  106. function exportData(encSelect) { 
  107. var enc = encSelect.options[encSelect.selectedIndex].value; 
  108. var url; 
  109. if (enc == 'GSS') { 
  110. if (typeof jQuery == 'function') { 
  111. try { 
  112. jQuery("#GoogleCredentialsDialog").dialog({ autoOpen: false, title: '<?php echo htmlspecialchars(__("Google Login for Upload", 'contact-form-7-to-database-extension')); ?>' }); 
  113. jQuery("#GoogleCredentialsDialog").dialog('open'); 
  114. jQuery("#guser").focus(); 
  115. catch (e) { 
  116. alert('Error: ' + e.message); 
  117. else { 
  118. alert("<?php echo htmlspecialchars(__('Cannot perform operation because jQuery is not loaded in this page', 'contact-form-7-to-database-extension')); ?>"); 
  119. else if (enc == 'GLD') { 
  120. alert("<?php echo htmlspecialchars(__('You will now be navigated to the builder page where it will generate a function to place in your Google Spreadsheet', 'contact-form-7-to-database-extension')); ?>"); 
  121. url = '<?php echo admin_url('admin.php') ?>?page=CF7DBPluginShortCodeBuilder&form=<?php echo urlencode($currSelection) ?>&enc=' + enc; 
  122. location.href = url; 
  123. else { 
  124. url = '<?php echo admin_url('admin-ajax.php') ?>?action=cfdb-export&form=<?php echo urlencode($currSelection) ?>&enc=' + enc; 
  125. var searchVal = getSearchFieldValue(); 
  126. if (searchVal != null && searchVal != "") { 
  127. url += '&search=' + encodeURIComponent(searchVal); 
  128. location.href = url; 
  129. function uploadGoogleSS() { 
  130. var key = '3fde789a'; 
  131. var guser = printHex(des(key, jQuery('#guser').attr('value'), 1)); 
  132. var gpwd = printHex(des(key, jQuery('#gpwd').attr('value'), 1)); 
  133. jQuery("#GoogleCredentialsDialog").dialog('close'); 
  134. var form = document.createElement("form"); 
  135. form.setAttribute("method", 'POST'); 
  136. var url = '<?php echo $pluginDirUrl ?>export.php?form=<?php echo urlencode($currSelection) ?>&enc=GSS'; 
  137. var searchVal = getSearchFieldValue(); 
  138. if (searchVal != null && searchVal != "") { 
  139. url += '&search=' + encodeURI(searchVal); 
  140. form.setAttribute("action", url); 
  141. var params = {guser: encodeURI(guser), gpwd: encodeURI(gpwd)}; 
  142. for (var pkey in params) { 
  143. var hiddenField = document.createElement("input"); 
  144. hiddenField.setAttribute("type", "hidden"); 
  145. hiddenField.setAttribute("name", pkey); 
  146. hiddenField.setAttribute("value", params[pkey]); 
  147. form.appendChild(hiddenField); 
  148. document.body.appendChild(form); 
  149. form.submit(); 
  150. </script> 
  151. <form name="exportcsv" action=""> 
  152. <input type="hidden" name="unbuffered" value="true"/> 
  153. <select size="1" name="enc"> 
  154. <option id="IQY" value="IQY"> 
  155. <?php echo htmlspecialchars(__('Excel Internet Query', 'contact-form-7-to-database-extension')); ?> 
  156. </option> 
  157. <option id="CSVUTF8BOM" value="CSVUTF8BOM"> 
  158. <?php echo htmlspecialchars(__('Excel CSV (UTF8-BOM)', 'contact-form-7-to-database-extension')); ?> 
  159. </option> 
  160. <option id="TSVUTF16LEBOM" value="TSVUTF16LEBOM"> 
  161. <?php echo htmlspecialchars(__('Excel TSV (UTF16LE-BOM)', 'contact-form-7-to-database-extension')); ?> 
  162. </option> 
  163. <option id="CSVUTF8" value="CSVUTF8"> 
  164. <?php echo htmlspecialchars(__('Plain CSV (UTF-8)', 'contact-form-7-to-database-extension')); ?> 
  165. </option> 
  166. <option id="CSVSJIS" value="CSVSJIS"> 
  167. <?php echo htmlspecialchars(__('Excel CSV for Japanese (Shift-JIS)', 'contact-form-7-to-database-extension')); ?> 
  168. </option> 
  169. <option id="GSS" value="GSS"> 
  170. <?php echo htmlspecialchars(__('Google Spreadsheet', 'contact-form-7-to-database-extension')); ?> 
  171. </option> 
  172. <option id="GLD" value="GLD"> 
  173. <?php echo htmlspecialchars(__('Google Spreadsheet Live Data', 'contact-form-7-to-database-extension')); ?> 
  174. </option> 
  175. <option id="HTML" value="HTML"> 
  176. <?php echo htmlspecialchars(__('HTML', 'contact-form-7-to-database-extension')); ?> 
  177. </option> 
  178. <option id="JSON" value="JSON"> 
  179. <?php echo htmlspecialchars(__('JSON', 'contact-form-7-to-database-extension')); ?> 
  180. </option> 
  181. </select> 
  182. <input name="exportButton" type="button" 
  183. value="<?php echo htmlspecialchars(__('Export', 'contact-form-7-to-database-extension')); ?>" 
  184. onclick="exportData(this.form.elements['enc'])"/> 
  185. <span style="font-size: x-small;"><br /><?php echo '<a href="admin.php?page=' . $plugin->getShortCodeBuilderPageSlug() . '">' . 
  186. __('Advanced Export', 'contact-form-7-to-database-extension') . '</a>' ?> 
  187. </form> 
  188. <?php } ?> 
  189. </td> 
  190. <td align="right" valign="top"> 
  191. <?php if ($currSelection && $canEdit) { ?> 
  192. <form action="" method="post"> 
  193. <input name="form_name" type="hidden" value="<?php echo $currSelectionEscaped ?>"/> 
  194. <input name="all" type="hidden" value="y"/> 
  195. <?php wp_nonce_field(); ?> 
  196. <input name="delete" type="submit" 
  197. value="<?php echo htmlspecialchars(__('Delete All This Form\'s Records', 'contact-form-7-to-database-extension')); ?>" 
  198. onclick="return confirm('<?php echo htmlspecialchars(__('Are you sure you want to delete all the data for this form?', 'contact-form-7-to-database-extension')); ?>')"/> 
  199. </form> 
  200. <br/> 
  201. <form action="" method="post"> 
  202. <input name="form_name" type="hidden" value="<?php echo $currSelectionEscaped ?>"/> 
  203. <?php wp_nonce_field(); ?> 
  204. <input name="delete_wpcf7" type="submit" 
  205. value="<?php echo htmlspecialchars(__('Remove _wpcf7 columns', 'contact-form-7-to-database-extension')) ?>"/> 
  206. </form> 
  207. <?php } ?> 
  208. </td> 
  209. </tr> 
  210. <?php 
  211. if ($currSelection && $canEdit && $useDataTables) { 
  212. ?> 
  213. <tr> 
  214. <td align="left" colspan="3"> 
  215. <span id="edit_controls"> 
  216. <a href="http://cfdbplugin.com/?page_id=459" target="_cfdbedit"><?php echo htmlspecialchars(__('Edit Data Mode', 'contact-form-7-to-database-extension')); ?></a> 
  217. </span> 
  218. </td> 
  219. </tr> 
  220. <?php 
  221. ?> 
  222. </table> 
  223.  
  224.  
  225. <?php 
  226. if ($currSelection) { 
  227. // Show table of form data 
  228. if ($useDataTables) { 
  229. $i18nUrl = $plugin->getDataTableTranslationUrl(); 
  230.  
  231. // Work out the datatable menu for number or rows shown 
  232. $maxVisible = $plugin->getOption('MaxVisibleRows', -1); 
  233. if (!is_numeric($maxVisible)) { 
  234. $maxVisible = -1; 
  235. $menuJS = $this->createDatatableLengthMenuJavascriptString($maxVisible); 
  236.  
  237. $sScrollX = $plugin->getOption('HorizontalScroll', 'true') == 'true' ? '"100%"' : '""'; 
  238. ?> 
  239. <script type="text/javascript" language="Javascript"> 
  240. var oTable; 
  241. jQuery(document).ready(function() { 
  242. oTable = jQuery('#<?php echo $tableHtmlId ?>').dataTable({ <?php // "sDom": 'Rlfrtip', // ColReorder ?> 
  243. "bJQueryUI": true,  
  244. "aaSorting": [],  
  245. //"sScrollY": "400",  
  246. "bScrollCollapse": true,  
  247. "sScrollX": <?php echo $sScrollX ?>,  
  248. "iDisplayLength": <?php echo $maxVisible ?>,  
  249. "aLengthMenu": <?php echo $menuJS ?> 
  250. <?php 
  251. if ($i18nUrl) { 
  252. echo ", \"oLanguage\": { \"sUrl\": \"$i18nUrl\" }"; 
  253. if ($canEdit) { 
  254. do_action_ref_array('cfdb_edit_fnDrawCallbackJSON', array($tableHtmlId)); 
  255.  
  256. ?> 
  257. }); 
  258. jQuery('th[id="delete_th"]').unbind('click'); <?php // Don't sort delete column ?> 
  259. }); 
  260.  
  261. </script> 
  262. <?php 
  263.  
  264. if ($canEdit) { 
  265. ?> 
  266. <form action="" method="post"> 
  267. <input name="form_name" type="hidden" value="<?php echo $currSelectionEscaped ?>"/> 
  268. <input name="delete" type="hidden" value="rows"/> 
  269. <?php wp_nonce_field(); ?> 
  270. <?php 
  271.  
  272. ?> 
  273. <?php 
  274. $exporter = new ExportToHtmlTable(); 
  275. $dbRowCount = $exporter->getDBRowCount($currSelection); 
  276. $maxRows = $plugin->getOption('MaxRows', '100'); 
  277. $startRow = $this->paginationDiv($plugin, $dbRowCount, $maxRows, $page); 
  278. ?> 
  279. <div <?php if (!$useDataTables) echo 'style="overflow:auto; max-height:500px; max-width:500px; min-width:75px"' ?>> 
  280. <?php 
  281. // Pick up any options that the user enters in the URL. 
  282. // This will include extraneous "form_name" and "page" GET params which are in the URL 
  283. // for this admin page 
  284. $options = array_merge($_POST, $_GET); 
  285. $options['canDelete'] = $canEdit; 
  286. if ($maxRows) { 
  287. $options['limit'] = ($startRow - 1) . ', ' . ($maxRows); 
  288. if ($useDataTables) { 
  289. $options['id'] = $tableHtmlId; 
  290. $options['class'] = ''; 
  291. $options['style'] = "#$tableHtmlId {padding:0;} #$tableHtmlId td > div { max-height: 100px; min-width:75px; overflow: auto; font-size: small;}"; // don't let cells get too tall 
  292. $exporter->export($currSelection, $options); 
  293. ?> 
  294. </div> 
  295. <?php if ($canEdit) { 
  296. ?> 
  297. </form> 
  298. <?php 
  299.  
  300. ?> 
  301. <script type="text/javascript"> 
  302. (function ($) { 
  303. var url = "admin.php?page=<?php echo $plugin->getDBPageSlug() ?>&form_name=<?php echo urlencode($currSelection) ?>&submit_time="; 
  304. $('td[title="Submitted"] div').each( 
  305. function () { 
  306. var submitTime = $(this).attr('id').split(", "); 
  307. $(this).html('<a target="_cfdb_entry" href="' + url + submitTime[0] + '">' + $(this).html() + '</a>'); 
  308. }) 
  309. })(jQuery); 
  310. </script> 
  311. <div style="margin-top:1em"> <?php // Footer ?> 
  312. <table style="width:100%;"> 
  313. <tbody> 
  314. <tr> 
  315. <td align="center" colspan="4"> 
  316. <span style="font-size:x-small; font-style: italic;"> 
  317. <?php echo htmlspecialchars(__('Did you know: This plugin captures data from both these plugins:', 'contact-form-7-to-database-extension')); ?> 
  318. <a target="_cf7" href="http://wordpress.org/extend/plugins/contact-form-7/">Contact Form 7</a>,  
  319. <a target="_fscf" href="http://wordpress.org/extend/plugins/si-contact-form/">Fast Secure Contact Form</a>,  
  320. <a target="_jetpack" href="http://wordpress.org/extend/plugins/jetpack/">JetPack Contact Form</a> 
  321. </span> 
  322. </td> 
  323. </tr> 
  324. <tr> 
  325. <td align="center" colspan="4"> 
  326. <span style="font-size:x-small; font-style: italic;"> 
  327. <?php echo htmlspecialchars(__('Did you know: You can add this data to your posts and pages using these shortcodes:', 'contact-form-7-to-database-extension')); ?> 
  328. <br/> 
  329. <a target="_faq" href="http://cfdbplugin.com/?page_id=284">[cfdb-html]</a> 
  330. <a target="_faq" href="http://cfdbplugin.com/?page_id=91">[cfdb-datatable]</a> 
  331. <a target="_faq" href="http://cfdbplugin.com/?page_id=93">[cfdb-table]</a> 
  332. <a target="_faq" href="http://cfdbplugin.com/?page_id=98">[cfdb-value]</a> 
  333. <a target="_faq" href="http://cfdbplugin.com/?page_id=278">[cfdb-count]</a> 
  334. <a target="_faq" href="http://cfdbplugin.com/?page_id=96">[cfdb-json]</a> 
  335. </span> 
  336. </td> 
  337. </tr> 
  338. <tr> 
  339. <td align="center" colspan="4"> 
  340. <span style="font-size:x-small; font-style: italic;"> 
  341. <?php echo htmlspecialchars(__('Would you like to help translate this plugin into your language?', 'contact-form-7-to-database-extension')); ?> 
  342. <a target="_i18n" 
  343. href="http://cfdbplugin.com/?page_id=7"><?php echo htmlspecialchars(__('How to create a translation', 'contact-form-7-to-database-extension')); ?></a> 
  344. </span> 
  345. </td> 
  346. </tr> 
  347. </tbody> 
  348. </table> 
  349. </div> 
  350. <?php 
  351. if ($currSelection && 'true' == $plugin->getOption('ShowQuery')) { 
  352. ?> 
  353. <div id="query" style="margin: 20px; border: dotted #d3d3d3 1pt;"> 
  354. <strong><?php echo htmlspecialchars(__('Query:', 'contact-form-7-to-database-extension')); ?></strong><br/> 
  355. <pre><?php echo $exporter->getPivotQuery($currSelection); ?></pre> 
  356. </div> 
  357. <?php 
  358.  
  359. if ($currSelection) { 
  360. ?> 
  361. <div id="GoogleCredentialsDialog" style="display:none; background-color:#EEEEEE;"> 
  362. <table> 
  363. <tbody> 
  364. <tr> 
  365. <td><label for="guser">User</label></td> 
  366. <td><input id="guser" type="text" size="25" value="@gmail.com"/></td> 
  367. </tr> 
  368. <tr> 
  369. <td><label for="gpwd">Password</label></td> 
  370. <td><input id="gpwd" type="password" size="25" value=""/></td> 
  371. </tr> 
  372. <tr> 
  373. <td></td> 
  374. <td> 
  375. <input type="button" value="<?php echo htmlspecialchars(__('Cancel', 'contact-form-7-to-database-extension')) ?>" 
  376. onclick="jQuery('#GoogleCredentialsDialog').dialog('close');"/> 
  377. <input type="button" value="<?php echo htmlspecialchars(__('Upload', 'contact-form-7-to-database-extension')) ?>" 
  378. onclick="uploadGoogleSS()"/> 
  379. </td> 
  380. </tr> 
  381. </tbody> 
  382. </table> 
  383. </div> 
  384. <script type="text/javascript" language="Javascript"> 
  385. var addColumnLabelText = '<?php echo htmlspecialchars(__('Add Column', 'contact-form-7-to-database-extension')); ?>'; 
  386. var deleteColumnLabelText = '<?php echo htmlspecialchars(__('Delete Column', 'contact-form-7-to-database-extension')); ?>'; 
  387. </script> 
  388. <?php 
  389. do_action_ref_array('cfdb_edit_setup', array($plugin)); 
  390.  
  391. /** 
  392. * @param $plugin CF7DBPlugin 
  393. * @param $totalRows integer 
  394. * @param $rowsPerPage integer 
  395. * @param $page integer 
  396. * @return integer $startRow 
  397. */ 
  398. protected function paginationDiv($plugin, $totalRows, $rowsPerPage, $page) { 
  399.  
  400. $nextLabel = __('next ', 'contact-form-7-to-database-extension'); 
  401. $prevLabel = __(' prev', 'contact-form-7-to-database-extension'); 
  402.  
  403. echo '<link rel="stylesheet" href="'; 
  404. echo $plugin->getPluginFileUrl(); 
  405. echo '/css/paginate.css'; 
  406. echo '" type="text/css"/>'; 
  407. // echo '<style type="text/css">'; 
  408. // include('css/paginate.css'); 
  409. // echo '</style>'; 
  410.  
  411.  
  412. if (!$page || $page < 1) $page = 1; //default to 1. 
  413. $startRow = $rowsPerPage * ($page - 1) + 1; 
  414.  
  415.  
  416. $endRow = min($startRow + $rowsPerPage - 1, $totalRows); 
  417. echo '<span style="margin-bottom:5px;">'; 
  418. printf(__('Returned entries %s to %s of %s entries in the database', 'contact-form-7-to-database-extension'),  
  419. $startRow, $endRow, $totalRows); 
  420. echo '</span>'; 
  421. echo '<div class="cfdb_paginate">'; 
  422.  
  423. $numPages = ($rowsPerPage > 0) ? ceil($totalRows / $rowsPerPage) : 1; 
  424. $adjacents = 3; 
  425.  
  426. /** Setup page vars for display. */ 
  427. $prev = $page - 1; //previous page is page - 1 
  428. $next = $page + 1; //next page is page + 1 
  429. $lastpage = $numPages; 
  430. $lpm1 = $lastpage - 1; //last page minus 1 
  431.  
  432. /** 
  433. Now we apply our rules and draw the pagination object. 
  434. We're actually saving the code to a variable in case we want to draw it more than once. 
  435. */ 
  436. if ($lastpage > 1) { 
  437. echo "<div class=\"pagination\">"; 
  438. //previous button 
  439. if ($page > 1) 
  440. echo $this->paginateLink($prev, $prevLabel); 
  441. else 
  442. echo "<span class=\"disabled\">$prevLabel</span>"; 
  443.  
  444. if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up 
  445. for ($counter = 1; $counter <= $lastpage; $counter++) 
  446. if ($counter == $page) 
  447. echo "<span class=\"current\">$counter</span>"; 
  448. else 
  449. echo $this->paginateLink($counter, $counter); 
  450. elseif ($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some 
  451. //close to beginning; only hide later pages 
  452. if ($page < 1 + ($adjacents * 2)) { 
  453. for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) 
  454. if ($counter == $page) 
  455. echo "<span class=\"current\">$counter</span>"; 
  456. else 
  457. echo $this->paginateLink($counter, $counter); 
  458. echo '...'; 
  459. echo $this->paginateLink($lpm1, $lpm1); 
  460. echo $this->paginateLink($lastpage, $lastpage); 
  461. //in middle; hide some front and some back 
  462. elseif ($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) 
  463. echo $this->paginateLink(1, 1); 
  464. echo $this->paginateLink(2, 2); 
  465. echo '...'; 
  466. for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) 
  467. if ($counter == $page) 
  468. echo "<span class=\"current\">$counter</span>"; 
  469. else 
  470. echo $this->paginateLink($counter, $counter); 
  471. echo '...'; 
  472. echo $this->paginateLink($lpm1, $lpm1); 
  473. echo $this->paginateLink($lastpage, $lastpage); 
  474. //close to end; only hide early pages 
  475. else 
  476. echo $this->paginateLink(1, 1); 
  477. echo $this->paginateLink(2, 2); 
  478. echo '...'; 
  479. for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) 
  480. if ($counter == $page) 
  481. echo "<span class=\"current\">$counter</span>"; 
  482. else 
  483. echo $this->paginateLink($counter, $counter); 
  484.  
  485. //next button 
  486. if ($page < $counter - 1) 
  487. echo $this->paginateLink($next, $nextLabel); 
  488. else 
  489. echo "<span class=\"disabled\">$nextLabel</span>"; 
  490. echo "</div>\n"; 
  491.  
  492. echo '</div>'; 
  493. return $startRow; 
  494.  
  495. protected function paginateLink($page, $label) { 
  496. return "<a href=\"#\" onclick=\"changeDbPage('$page');\">$label</a>"; 
  497.  
  498. /** 
  499. * Create aLengthMenu javascript string for databatable 
  500. * @param $maxVisible 
  501. * @return string 
  502. */ 
  503. protected function createDatatableLengthMenuJavascriptString($maxVisible) { 
  504. $numRowsMenu = array(); 
  505. $found = $maxVisible == -1; 
  506. foreach (array(1, 2, 3, 4, 5, 10, 25, 50, 100) as $entry) { 
  507. if ($found) { 
  508. $numRowsMenu[] = $entry; 
  509. } else { 
  510. if ($maxVisible == $entry) { 
  511. $found = true; 
  512. } else if ($maxVisible < $entry) { 
  513. $numRowsMenu[] = $maxVisible; 
  514. $found = true; 
  515. $numRowsMenu[] = $entry; 
  516. if (!$found) { 
  517. $numRowsMenu[] = $maxVisible; 
  518. $numRowsMenu[] = -1; 
  519.  
  520. $menuJS1 = '[['; 
  521. $menuJS2 = ', ['; 
  522. foreach ($numRowsMenu as $val) { 
  523. $menuJS1 .= $val . ', '; 
  524. if ($val == -1) { 
  525. $val = '"' . __('All', 'contact-form-7-to-database-extension') . '"'; 
  526. $menuJS2 .= $val . ', '; 
  527. $menuJS1 = substr($menuJS1, 0, -1) . ']'; 
  528. $menuJS2 = substr($menuJS2, 0, -1) . ']]'; 
  529. return $menuJS1 . $menuJS2; 
  530.