1: <?php
2:
3: 4: 5:
6: class Quform_Entry_List_Table extends WP_List_Table
7: {
8: 9: 10:
11: protected $page;
12:
13: 14: 15:
16: protected $form;
17:
18: 19: 20:
21: protected $repository;
22:
23: 24: 25:
26: protected $options;
27:
28: 29: 30:
31: protected $labels;
32:
33: 34: 35:
36: protected $view;
37:
38: 39: 40: 41: 42: 43:
44: public function __construct(Quform_Admin_Page_Entries_List $page, Quform_Form $form, Quform_Repository $repository, Quform_Options $options)
45: {
46: parent::__construct(array(
47: 'singular' => 'qfb-entry',
48: 'plural' => 'qfb-entries'
49: ));
50:
51: $this->page = $page;
52: $this->form = $form;
53: $this->repository = $repository;
54: $this->options = $options;
55: $this->labels = $this->repository->getFormEntryLabels($form->getId());
56: }
57:
58: 59: 60:
61: public function prepare_items()
62: {
63: $this->view = Quform::get($_GET, 'view');
64: $perPage = $this->get_items_per_page('quform_entries_per_page');
65:
66: $args = array(
67: 'unread' => null,
68: 'orderby' => $this->getOrderBy(strtolower((string) Quform::get($_GET, 'orderby'))),
69: 'order' => $this->getOrder(strtolower((string) Quform::get($_GET, 'order'))),
70: 'status' => 'normal',
71: 'limit' => $perPage,
72: 'offset' => ($this->get_pagenum() - 1) * $perPage,
73: 'search' => isset($_GET['s']) && Quform::isNonEmptyString($_GET['s']) ? wp_unslash($_GET['s']) : '',
74: 'labels' => isset($_GET['labels']) && is_array($_GET['labels']) ? $_GET['labels'] : array(),
75: 'label_operator' => isset($_GET['label_operator']) ? $_GET['label_operator'] : 'OR'
76: );
77:
78: switch ($this->view) {
79: case 'read':
80: $args['unread'] = false;
81: break;
82: case 'unread':
83: $args['unread'] = true;
84: break;
85: case 'trashed':
86: $args['status'] = 'trash';
87: break;
88: }
89:
90: $args = apply_filters('quform_entry_list_table_args', $args, $this, $this->form);
91: $args = apply_filters('quform_entry_list_table_args_' . $this->form->getId(), $args, $this, $this->form);
92:
93: $this->items = $this->repository->listEntries($this->form, $this->getColumns(), $args);
94:
95: $foundItems = $this->repository->getFoundRows();
96:
97: $this->set_pagination_args(array(
98: 'total_items' => $foundItems,
99: 'total_pages' => ceil($foundItems / $args['limit']),
100: 'per_page' => $args['limit']
101: ));
102: }
103:
104: 105: 106:
107: public function views()
108: {
109: $views = $this->get_views();
110:
111: if (empty($views)) {
112: return;
113: }
114:
115: echo '<div class="qfb-sub-nav qfb-cf">';
116: echo '<ul class="qfb-sub-nav-ul">';
117:
118: foreach ($views as $class => $view) {
119: printf('<li class="qfb-view-%s">%s</li>', $class, $view);
120: }
121:
122: echo '</ul>';
123: echo '</div>';
124: }
125:
126: 127: 128: 129: 130:
131: protected function get_views()
132: {
133: $isSearch = (isset($_GET['s']) && Quform::isNonEmptyString($_GET['s'])) || isset($_GET['labels']);
134: $views = array();
135:
136: $views['all'] = sprintf(
137: '<a href="%s" class="%s">%s <span class="count">(%s)</span></a>',
138: esc_url(admin_url(sprintf('admin.php?page=quform.entries&id=%d', $this->form->getId()))),
139: $this->view === null && !$isSearch ? 'qfb-current' : '',
140: esc_html__('All', 'quform'),
141: number_format_i18n($this->repository->getEntryCount($this->form->getId()))
142: );
143:
144: $views['unread'] = sprintf(
145: '<a href="%s" class="%s">%s <span class="count">(%s)</span></a>',
146: esc_url(admin_url(sprintf('admin.php?page=quform.entries&id=%d&view=unread', $this->form->getId()))),
147: $this->view === 'unread' && !$isSearch ? 'qfb-current' : '',
148: esc_html__('Unread', 'quform'),
149: number_format_i18n($this->repository->getEntryCount($this->form->getId(), true))
150: );
151:
152: $views['read'] = sprintf(
153: '<a href="%s" class="%s">%s <span class="count">(%s)</span></a>',
154: esc_url(admin_url(sprintf('admin.php?page=quform.entries&id=%d&view=read', $this->form->getId()))),
155: $this->view === 'read' && !$isSearch ? 'qfb-current' : '',
156: esc_html__('Read', 'quform'),
157: number_format_i18n($this->repository->getEntryCount($this->form->getId(), false))
158: );
159:
160: $views['trash'] = sprintf(
161: '<a href="%s" class="%s">%s <span class="count">(%s)</span></a>',
162: esc_url(admin_url(sprintf('admin.php?page=quform.entries&id=%d&view=trashed', $this->form->getId()))),
163: $this->view === 'trashed' && !$isSearch ? 'qfb-current' : '',
164: esc_html__('Trash', 'quform'),
165: number_format_i18n($this->repository->getEntryCount($this->form->getId(), null, 'trash'))
166: );
167:
168: if ($isSearch) {
169: if (isset($_GET['s']) && Quform::isNonEmptyString($_GET['s'])) {
170:
171: $searchText = sprintf(__('Search results for “%s”', 'quform'), wp_unslash($_GET['s']));
172: } else {
173: $searchText = __('Search results', 'quform');
174: }
175:
176: $views['search'] = sprintf(
177: '<a class="qfb-current">%s <span class="count">(%s)</span></a>',
178: esc_html($searchText),
179: number_format_i18n($this->_pagination_args['total_items'])
180: );
181: }
182:
183: return $views;
184: }
185:
186: 187: 188: 189: 190:
191: public function get_columns()
192: {
193: $columns = array('cb' => '<input type="checkbox" />');
194:
195: if (count($this->labels)) {
196: $columns['labels'] = '';
197: }
198:
199: if ($this->view != 'trashed') {
200: $columns['icon'] = '';
201: }
202:
203: foreach ($this->getColumns() as $column) {
204: $columns[$column] = Quform::escape($this->getColumnLabel($column));
205: }
206:
207: return $columns;
208: }
209:
210: 211: 212: 213: 214:
215: protected function getColumns()
216: {
217: $columns = $this->form->config('entriesTableColumns');
218:
219: if (count($columns)) {
220: $columns = array_values(array_filter($columns, array($this, 'filterMissingElement')));
221: } else {
222: $columns = $this->getDefaultColumns();
223: }
224:
225: $columns = apply_filters('quform_entry_list_table_columns', $columns, $this, $this->form);
226: $columns = apply_filters('quform_entry_list_table_columns_' . $this->form->getId(), $columns, $this, $this->form);
227:
228: return $columns;
229: }
230:
231: 232: 233: 234: 235: 236:
237: protected function filterMissingElement($column)
238: {
239: if (preg_match('/^element_\d+/', $column)) {
240: $elementId = (int) str_replace('element_', '', $column);
241: $element = $this->form->getElementById($elementId);
242:
243: if ( ! $element instanceof Quform_Element_Field) {
244: return false;
245: }
246: }
247:
248: return true;
249: }
250:
251: 252: 253: 254: 255: 256:
257: public function getColumnLabel($column)
258: {
259: $label = '';
260:
261: if (preg_match('/^element_\d+/', $column)) {
262: static $adminLabelMap;
263:
264: if (!is_array($adminLabelMap)) {
265: $adminLabelMap = array();
266:
267: foreach ($this->form->getRecursiveIterator(RecursiveIteratorIterator::SELF_FIRST) as $element) {
268: if ($element instanceof Quform_Element_Field) {
269: $adminLabelMap['element_' . $element->getId()] = $element->getAdminLabel();
270: }
271: }
272: }
273:
274: if (isset($adminLabelMap[$column])) {
275: $label = $adminLabelMap[$column];
276: }
277: } else {
278: switch ($column) {
279: case 'created_at':
280: $label = __('Date', 'quform');
281: break;
282: case 'updated_at':
283: $label = __('Last modified', 'quform');
284: break;
285: case 'form_url':
286: $label = __('Form URL', 'quform');
287: break;
288: case 'referring_url':
289: $label = __('Referring URL', 'quform');
290: break;
291: case 'post_id':
292: $label = __('Page', 'quform');
293: break;
294: case 'created_by':
295: $label = __('User', 'quform');
296: break;
297: case 'id':
298: $label = __('ID', 'quform');
299: break;
300: case 'ip':
301: $label = __('IP address', 'quform');
302: break;
303: }
304: }
305:
306: return $label;
307: }
308:
309: 310: 311: 312: 313: 314: 315:
316: protected function getDefaultColumns()
317: {
318: $columns = array('created_at');
319: $i = 0;
320:
321: foreach ($this->form->getRecursiveIterator() as $element) {
322: if ($element instanceof Quform_Element_Field && $element->config('saveToDatabase')) {
323: $columns[] = sprintf('element_%d', $element->getId());
324: }
325:
326: $i++;
327:
328: if ($i > 3) {
329: break;
330: }
331: }
332:
333: return $columns;
334: }
335:
336: 337: 338: 339: 340:
341: protected function getAllColumns()
342: {
343: $columns = array('created_at', 'form_url', 'referring_url', 'post_id', 'created_by', 'updated_at', 'ip', 'id');
344:
345: foreach ($this->form->getRecursiveIterator() as $element) {
346: if ($element instanceof Quform_Element_Field && $element->config('saveToDatabase')) {
347: $columns[] = sprintf('element_%d', $element->getId());
348: }
349: }
350:
351: return $columns;
352: }
353:
354: 355: 356: 357: 358:
359: public function getColumnLayoutSortableHtml()
360: {
361: $columns = $this->getColumns();
362:
363: $output = '<div class="qfb-entries-table-layout-active">';
364: $output .= sprintf('<div class="qfb-entries-table-layout-heading">%s</div>', esc_html__('Active columns', 'quform'));
365: $output .= '<div id="qfb-active-columns">';
366:
367: foreach ($columns as $column) {
368: $output .= sprintf(
369: '<div class="qfb-button" data-column="%s">%s</div>',
370: Quform::escape($column),
371: Quform::escape($this->getColumnLabel($column))
372: );
373: }
374:
375: $output .= '</div></div>';
376: $output .= '<div class="qfb-entries-table-layout-inactive">';
377: $output .= sprintf('<div class="qfb-entries-table-layout-heading">%s</div>', esc_html__('Inactive columns', 'quform'));
378: $output .= '<div id="qfb-inactive-columns">';
379:
380: foreach ($this->getAllColumns() as $column) {
381: if (in_array($column, $columns)) {
382: continue;
383: }
384:
385: $output .= sprintf(
386: '<div class="qfb-button" data-column="%s">%s</div>',
387: Quform::escape($column),
388: Quform::escape($this->getColumnLabel($column))
389: );
390: }
391:
392: $output .= '</div></div>';
393:
394: return $output;
395: }
396:
397: 398: 399: 400: 401:
402: protected function get_default_primary_column_name() {
403: $columns = $this->get_columns();
404: $column = '';
405:
406: if (empty($columns)) {
407: return $column;
408: }
409:
410: foreach ($columns as $col => $column_name) {
411: if ('cb' == $col || 'icon' == $col || 'labels' == $col) {
412: continue;
413: }
414:
415: $column = $col;
416: break;
417: }
418:
419: return $column;
420: }
421:
422: 423: 424: 425: 426:
427: protected function get_sortable_columns()
428: {
429: $orderBy = $this->getOrderBy();
430: $isAsc = $this->getOrder() == 'asc';
431: $columns = array();
432:
433: foreach ($this->getColumns() as $column) {
434: if ($column == 'created_at') {
435: $columns[$column] = array($column, ! ($orderBy == $column && ! $isAsc));
436: } else {
437: $columns[$column] = array($column, $orderBy == $column && $isAsc);
438: }
439: }
440:
441: return $columns;
442: }
443:
444: 445: 446: 447: 448:
449: public function single_row($item)
450: {
451: $this->form->setEntryId((int) $item['id']);
452:
453: echo sprintf('<tr%s>', $item['unread'] == '1' ? ' class="qfb-entry-unread"' : '');
454: $this->single_row_columns( $item );
455: echo '</tr>';
456: }
457:
458: 459: 460: 461: 462: 463:
464: protected function column_cb($item)
465: {
466: return sprintf('<input type="checkbox" name="eids[]" value="%s" />', $item['id']);
467: }
468:
469: 470: 471: 472: 473: 474: 475:
476: protected function _column_icon($item, $classes)
477: {
478: $output = sprintf('<th class="%s">', esc_attr($classes));
479:
480: if ($item['unread'] == '1') {
481: $output .= '<i class="qfb-icon qfb-icon-envelope"></i>';
482: } else {
483: $output .= '<i class="qfb-icon qfb-icon-envelope-open-o"></i>';
484: }
485:
486: $output .= '</th>';
487:
488: return $output;
489: }
490:
491: 492: 493: 494: 495: 496: 497:
498: protected function _column_labels($item, $classes)
499: {
500: $output = sprintf('<th class="%s" data-entry-id="%d">', esc_attr($classes), esc_attr($item['id']));
501:
502: $labels = array();
503:
504: if (Quform::isNonEmptyString($item['labels'])) {
505: foreach (explode(',', $item['labels']) as $label) {
506: $label = $this->getLabelById($label);
507:
508: if (is_array($label)) {
509: $labels[] = $label;
510: }
511: }
512: }
513:
514: $output .= $this->page->getEntryLabelsHtml($labels);
515:
516: $output .= '</th>';
517:
518: return $output;
519: }
520:
521: 522: 523: 524: 525: 526:
527: protected function getLabelById($id)
528: {
529: foreach ($this->labels as $label) {
530: if ($id == $label['id']) {
531: return $label;
532: }
533: }
534:
535: return null;
536: }
537:
538: 539: 540: 541: 542: 543: 544: 545:
546: protected function handle_row_actions($item, $column_name, $primary)
547: {
548: if ($column_name != $primary) {
549: return '';
550: }
551:
552: $actions = array();
553:
554: if ($item['status'] == 'normal') {
555: if (current_user_can('quform_view_entries')) {
556: $actions['view'] = sprintf(
557: '<a href="%s" aria-label="%s">%s</a>',
558: esc_url(add_query_arg(array('sp' => 'view', 'eid' => $item['id'], 'id' => false))),
559: esc_attr__('View this entry', 'quform'),
560: esc_html__('View', 'quform')
561: );
562: }
563:
564: if (current_user_can('quform_edit_entries')) {
565: $actions['edit'] = sprintf(
566: '<a href="%s" aria-label="%s">%s</a>',
567: esc_url(add_query_arg(array('sp' => 'edit', 'eid' => $item['id'], 'id' => false))),
568: esc_attr__('Edit this entry', 'quform'),
569: esc_html__('Edit', 'quform')
570: );
571: }
572:
573: if (current_user_can('quform_view_entries')) {
574: if ($item['unread'] == '1') {
575: $actions['read'] = sprintf(
576: '<a href="%s" aria-label="%s">%s</a>',
577: esc_url(add_query_arg(array('action' => 'read', 'eid' => $item['id'], '_wpnonce' => wp_create_nonce('quform_read_entry_' . $item['id'])))),
578: esc_attr__('Mark this entry as read', 'quform'),
579: esc_html__('Mark as read', 'quform')
580: );
581: } else {
582: $actions['unread'] = sprintf(
583: '<a href="%s" aria-label="%s">%s</a>',
584: esc_url(add_query_arg(array('action' => 'unread', 'eid' => $item['id'], '_wpnonce' => wp_create_nonce('quform_unread_entry_' . $item['id'])))),
585: esc_attr__('Mark this entry as unread', 'quform'),
586: esc_html__('Mark as unread', 'quform')
587: );
588: }
589: }
590:
591: if (current_user_can('quform_delete_entries')) {
592: $actions['trash'] = sprintf(
593: '<a href="%s" aria-label="%s">%s</a>',
594: esc_url(add_query_arg(array('action' => 'trash', 'eid' => $item['id'], '_wpnonce' => wp_create_nonce('quform_trash_entry_' . $item['id'])))),
595: esc_attr__('Move this entry to the Trash', 'quform'),
596: esc_html__('Trash', 'quform')
597: );
598: }
599: } elseif ($item['status'] == 'trash') {
600: if (current_user_can('quform_delete_entries')) {
601: $actions['untrash'] = sprintf(
602: '<a href="%s" aria-label="%s">%s</a>',
603: esc_url(add_query_arg(array('action' => 'untrash', 'eid' => $item['id'], '_wpnonce' => wp_create_nonce('quform_untrash_entry_' . $item['id'])))),
604: esc_attr__('Restore this entry from the Trash', 'quform'),
605: esc_html__('Restore', 'quform')
606: );
607:
608: $actions['delete'] = sprintf(
609: '<a href="%s" aria-label="%s">%s</a>',
610: esc_url(add_query_arg(array('action' => 'delete', 'eid' => $item['id'], '_wpnonce' => wp_create_nonce('quform_delete_entry_' . $item['id'])))),
611: esc_attr__('Delete this entry permanently', 'quform'),
612: esc_html__('Delete permanently', 'quform')
613: );
614: }
615: }
616:
617: return $this->row_actions($actions);
618: }
619:
620: 621: 622: 623: 624: 625: 626:
627: protected function column_default($item, $columnName)
628: {
629: if (preg_match('/^element_\d+/', $columnName)) {
630: return $this->columnElement($item, $columnName);
631: }
632:
633: $output = '';
634:
635: switch ($columnName) {
636: case 'created_at':
637: $output = esc_html($this->options->formatDate($item['created_at'], true));
638: break;
639: case 'updated_at':
640: $output = esc_html($this->options->formatDate($item['updated_at'], true));
641: break;
642: case 'form_url':
643: if ( ! empty($item['form_url'])) {
644: $output = '<a href="' . esc_url($item['form_url']) . '" target="_blank">' . esc_html($item['form_url']) . '</a>';
645: }
646: break;
647: case 'referring_url':
648: if ( ! empty($item['referring_url'])) {
649: $output = '<a href="' . esc_url($item['referring_url']) . '" target="_blank">' . esc_html($item['referring_url']) . '</a>';
650: }
651: break;
652: case 'created_by':
653: $user = get_user_by('id', $item['created_by']);
654:
655: if ($user instanceof WP_User) {
656: $link = get_edit_user_link($user->ID);
657:
658: if ( ! empty($link)) {
659: $output = '<a href="' . esc_url($link) . '" title="' . esc_attr('View user profile', 'quform') . '" target="_blank">' . esc_html($user->user_login) . '</a>';
660: } else {
661: $output = esc_html($user->user_login);
662: }
663: }
664: break;
665: case 'post_id':
666: $post = get_post($item['post_id']);
667:
668: if ($post instanceof WP_Post) {
669: $link = get_permalink($post->ID);
670:
671: if ( ! empty($link)) {
672: $output = '<a href="' . esc_url($link) . '" title="' . esc_attr('View page', 'quform') . '" target="_blank">' . esc_html(get_the_title($post->ID)) . '</a>';
673: } else {
674: $output = esc_html(get_the_title($post->ID));
675: }
676: }
677: break;
678: default:
679: $output = isset($item[$columnName]) ? esc_html($item[$columnName]) : '';
680: break;
681:
682: }
683:
684: return $this->linkIfPrimaryColumn($output, $item, $columnName);
685: }
686:
687: 688: 689: 690: 691: 692: 693:
694: protected function columnElement($item, $columnName)
695: {
696: $elementId = (int) str_replace('element_', '', $columnName);
697: $element = $this->form->getElementById($elementId);
698: $output = '';
699:
700: if ($element instanceof Quform_Element_Field) {
701: if (isset($item[$columnName])) {
702: $element->setValueFromStorage($item[$columnName]);
703: } else {
704: $element->setValue($element->getEmptyValue());
705: }
706:
707: $output = $element->getValueHtml();
708: }
709:
710: return $this->linkIfPrimaryColumn($output, $item, $columnName);
711: }
712:
713: 714: 715: 716: 717: 718:
719: protected function get_bulk_actions()
720: {
721: $actions = array();
722:
723: if ($this->view == 'trashed') {
724: if (current_user_can('quform_delete_entries')) {
725: $actions['untrash'] = __('Restore', 'quform');
726: $actions['delete'] = __('Delete permanently', 'quform');
727: }
728: } else {
729: $actions['read'] = __('Mark as read', 'quform');
730: $actions['unread'] = __('Mark as unread', 'quform');
731:
732: if (current_user_can('quform_delete_entries')) {
733: $actions['trash'] = __('Move to Trash', 'quform');
734: }
735: }
736:
737: return $actions;
738: }
739:
740: 741: 742: 743: 744:
745: public function getLabelSearchHtml()
746: {
747: if ( ! count($this->labels)) {
748: return '';
749: }
750:
751: $selectedLabels = isset($_GET['labels']) && is_array($_GET['labels']) ? $_GET['labels'] : array();
752:
753: $output = '<div id="qfb-entry-label-search-trigger" class="qfb-entry-label-search-trigger"><i class="qfb-icon qfb-icon-tags"></i></div>';
754: $output .= '<div id="qfb-entry-label-search" class="qfb-entry-label-search">';
755:
756: foreach ($this->labels as $label) {
757: $output .= sprintf(
758: '<div class="qfb-entry-label%s" style="background-color:%s" data-id="%d"><span class="qfb-entry-label-name">%s</span><i class="qfb-icon qfb-icon-check"></i></div>',
759: in_array($label['id'], $selectedLabels) ? ' qfb-label-selected' : '',
760: Quform::escape($label['color']),
761: Quform::escape($label['id']),
762: Quform::escape($label['name'])
763: );
764: }
765:
766: $output .= '<select id="qfb-entry-label-search-ids" name="labels[]" multiple>';
767:
768: foreach ($this->labels as $label) {
769: $output .= sprintf(
770: '<option value="%s"%s>%s</option>',
771: Quform::escape($label['id']),
772: in_array($label['id'], $selectedLabels) ? ' selected="selected"' : '',
773: Quform::isNonEmptyString($label['name']) ? Quform::escape($label['name']) : Quform::escape(__('Untitled', 'quform'))
774: );
775: }
776:
777: $output .= '</select>';
778:
779: $output .= '<select name="label_operator">';
780:
781: $output .= sprintf(
782: '<option value="or"%s>%s</option>',
783: isset($_GET['label_operator']) && $_GET['label_operator'] == 'or' ? ' selected="selected"' : '',
784: esc_html__('Match any label', 'quform')
785: );
786:
787: $output .= sprintf(
788: '<option value="and"%s>%s</option>',
789: isset($_GET['label_operator']) && $_GET['label_operator'] == 'and' ? ' selected="selected"' : '',
790: esc_html__('Match all labels', 'quform')
791: );
792:
793: $output .= '</select>';
794:
795: $output .= sprintf('<input type="submit" class="button" value="%s">', esc_attr__('Search', 'quform'));
796:
797: $output .= '</div>';
798:
799: return $output;
800: }
801:
802: 803: 804: 805: 806: 807: 808: 809:
810: protected function linkIfPrimaryColumn($output, $item, $columnName)
811: {
812: if ($columnName == $this->get_default_primary_column_name()) {
813: $output = sprintf(
814: '<strong><a href="%s" aria-label="%s">%s</a></strong>',
815: esc_url(add_query_arg(array('sp' => 'view', 'eid' => $item['id'], 'id' => false))),
816: esc_attr__('View this entry', 'quform'),
817: $output
818: );
819: }
820:
821: return $output;
822: }
823:
824: 825: 826:
827: public function no_items() {
828: if (isset($_GET['s']) && Quform::isNonEmptyString($_GET['s'])) {
829: esc_html_e('Your search did not match any entries.', 'quform');
830: } elseif ($this->view == 'trashed') {
831: esc_html_e('No entries found in Trash.', 'quform');
832: } else {
833: esc_html_e('No entries found.', 'quform');
834: }
835: }
836:
837: 838: 839: 840: 841: 842: 843: 844:
845: public function search_box( $text, $input_id ) {
846: $input_id = $input_id . '-search-input';
847:
848: if ( ! empty( $_REQUEST['orderby'] ) )
849: echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
850: if ( ! empty( $_REQUEST['order'] ) )
851: echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
852: if ( ! empty( $_REQUEST['post_mime_type'] ) )
853: echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />';
854: if ( ! empty( $_REQUEST['detached'] ) )
855: echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />';
856: ?>
857: <p class="search-box">
858: <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
859: <input type="search" id="<?php echo esc_attr( $input_id ); ?>" name="s" value="<?php _admin_search_query(); ?>" />
860: <?php submit_button( $text, '', '', false, array( 'id' => 'search-submit' ) ); ?>
861: </p>
862: <?php
863: }
864:
865: 866: 867: 868: 869: 870: 871: 872:
873: protected function getOrderBy($requestedOrderBy = '')
874: {
875: $currentUserId = get_current_user_id();
876: $userOrderBy = get_user_meta($currentUserId, 'quform_entries_order_by', true);
877:
878: if (Quform::isNonEmptyString($requestedOrderBy)) {
879: $orderBy = $requestedOrderBy;
880:
881: if ($requestedOrderBy != $userOrderBy) {
882: update_user_meta($currentUserId, 'quform_entries_order_by', $requestedOrderBy);
883: }
884: } elseif (Quform::isNonEmptyString($userOrderBy)) {
885: $orderBy = $userOrderBy;
886: } else {
887: $orderBy = 'created_at';
888: }
889:
890: return $orderBy;
891: }
892:
893: 894: 895: 896: 897: 898: 899: 900:
901: protected function getOrder($requestedOrder = '')
902: {
903: $currentUserId = get_current_user_id();
904: $userOrder = get_user_meta($currentUserId, 'quform_entries_order', true);
905:
906: if (Quform::isNonEmptyString($requestedOrder)) {
907: $order = $requestedOrder;
908:
909: if ($requestedOrder != $userOrder) {
910: update_user_meta($currentUserId, 'quform_entries_order', $requestedOrder);
911: }
912: } elseif (Quform::isNonEmptyString($userOrder)) {
913: $order = $userOrder;
914: } else {
915: $order = 'desc';
916: }
917:
918: return $order;
919: }
920:
921: 922: 923: 924: 925:
926: protected function extra_tablenav($which)
927: {
928: if ($which == 'top' && $this->view == 'trashed' && count($this->items) && current_user_can('quform_delete_entries')) {
929: submit_button(__('Empty Trash', 'quform'), 'apply', 'delete_all', false);
930: }
931: }
932: }
933: