Caldera_Forms_Entry_Viewer

Creates entry viewer.

Defined (1)

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

/classes/entry/viewer.php  
  1. class Caldera_Forms_Entry_Viewer { 
  2.  
  3. /** 
  4. * Get full viewer system 
  5. * Designed for use in admin 
  6. * @since 1.5.0 
  7. * @return string 
  8. */ 
  9. public static function full_viewer( $with_toolbar = true ) { 
  10. ob_start(); 
  11. include CFCORE_PATH . 'ui/entries/viewer.php'; 
  12. return ob_get_clean(); 
  13.  
  14. /** 
  15. * Print necessary scripts or admin viewer 
  16. * @since 1.5.0 
  17. */ 
  18. public static function print_scripts() { 
  19. include CFCORE_PATH . 'ui/entries/scripts_templates.php'; 
  20.  
  21. /** 
  22. * Create span that triggers AJAX action for loading a single form's entries into viewer 
  23. * @since 1.5.0 
  24. * @param string $form_id The from ID 
  25. * @return string 
  26. */ 
  27. public static function entry_trigger( $form_id ) { 
  28. $atts = array( 
  29. 'class' => 'form-control form-entry-trigger ajax-trigger',  
  30. 'id' => esc_attr( 'entry-trigger-' . trim( $form_id ) ),  
  31. 'data-autoload' => 'true',  
  32. 'data-page' => '1',  
  33. 'data-status' => 'active',  
  34. 'data-callback' => 'setup_pagination',  
  35. 'data-group' => 'entry_nav',  
  36. 'data-active-class' => 'highlight',  
  37. 'data-load-class' => 'spinner',  
  38. 'data-active-element' => '#form_row_' . $form_id,  
  39. 'data-template' => '#forms-list-alt-tmpl',  
  40. 'data-form' => $form_id,  
  41. 'data-target' => '#form-entries-viewer',  
  42. 'data-action' => 'browse_entries',  
  43. 'data-nonce' => wp_create_nonce( 'view_entries' ),  
  44. ); 
  45.  
  46. return sprintf( '<span %s ></span>', caldera_forms_implode_field_attributes( caldera_forms_escape_field_attributes_array( $atts ) ) ); 
  47.  
  48.  
  49. /** 
  50. * Show entry viewer (v1) for one form 
  51. * @since 1.5.0 
  52. * @param $form_id 
  53. * @param bool $with_toolbar 
  54. * @return string 
  55. */ 
  56. public static function form_entry_viewer_1( $form_id, $with_toolbar = false ) { 
  57. Caldera_Forms_Admin_Assets::admin_common(); 
  58.  
  59.  
  60. $viewer = self::full_viewer( $with_toolbar ); 
  61. $viewer .= self::entry_trigger( $form_id ); 
  62. if( ! did_action( 'wp_footer' ) ) { 
  63. add_action( 'wp_footer', array( __CLASS__, 'print_scripts' ) ); 
  64. }else{ 
  65. ob_start(); 
  66. self::print_scripts(); 
  67. $viewer .= ob_get_clean(); 
  68.  
  69. return $viewer; 
  70.  
  71.  
  72. /** 
  73. * Get saved # of entries per page to show 
  74. * @since 1.5.0 
  75. * @return int 
  76. */ 
  77. public static function entries_per_page() { 
  78. return absint( get_option( '_caldera_forms_entry_perpage', 20 ) ); 
  79.  
  80. /** 
  81. * Updated saved # of entries per page to show 
  82. * @since 1.5.0 
  83. * @param int $per_page New value 
  84. * @return int 
  85. */ 
  86. public static function update_entries_per_page( $per_page ) { 
  87. update_option( '_caldera_forms_entry_perpage', absint( $per_page ) ); 
  88. return self::entries_per_page(); 
  89.  
  90. /** 
  91. * Factory Caldera_Forms_Entry_Vue class that creates entry viewer v2 
  92. * Enqueues script and outputs HTML 
  93. * @since 1.5.0 
  94. * @param array $form Form config 
  95. * @return string Rendered HTML of entry viewer 
  96. */ 
  97. public static function form_entry_viewer_2( array $form, $config = array() ) { 
  98. $vue = new Caldera_Forms_Entry_Vue( $form, $config ); 
  99. return $vue->display(); 
  100.  
  101.