PodsBuilderModuleView

The Pods - Custom Content Types and Fields PodsBuilderModuleView class.

Defined (1)

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

/components/Builder/modules/view/PodsBuilderModuleView.php  
  1. class PodsBuilderModuleView extends LayoutModule { 
  2.  
  3. var $_name = ''; 
  4. var $_var = 'pods-builder-view'; 
  5. var $_description = ''; 
  6. var $_editor_width = 500; 
  7. var $_can_remove_wrappers = true; 
  8.  
  9. /** 
  10. * Register the Module 
  11. */ 
  12. public function PodsBuilderModuleView () { 
  13. $this->_name = __( 'Pods - View', 'pods' ); 
  14. $this->_description = __( "Include a file from a theme, with caching options", 'pods' ); 
  15. $this->module_path = dirname( __FILE__ ); 
  16.  
  17. $this->LayoutModule(); 
  18.  
  19. /** 
  20. * Set default variables 
  21. * @param $defaults 
  22. * @return mixed 
  23. */ 
  24. function _get_defaults ( $defaults ) { 
  25. $new_defaults = array( 
  26. 'view' => '',  
  27. 'expires' => 0,  
  28. 'cache_mode' => 'none' 
  29. ); 
  30.  
  31. return ITUtility::merge_defaults( $new_defaults, $defaults ); 
  32.  
  33. /** 
  34. * Output something before the table form 
  35. * @param object $form Form class 
  36. * @param bool $results 
  37. */ 
  38. function _before_table_edit ( $form, $results = true ) { 
  39. ?> 
  40. <p><?php echo $this->_description; ?></p> 
  41. <?php 
  42.  
  43. /** 
  44. * Output something at the start of the table form 
  45. * @param object $form Form class 
  46. * @param bool $results 
  47. */ 
  48. function _start_table_edit ( $form, $results = true ) { 
  49. ?> 
  50. <tr> 
  51. <td valign="top"> 
  52. <label for="view"><?php _e( 'File to include', 'pods' ); ?></label> 
  53. </td> 
  54. <td> 
  55. <?php $form->add_text_box( 'view' ); ?> 
  56. </td> 
  57. </tr> 
  58. <tr> 
  59. <td valign="top"> 
  60. <label for="cache_mode"><?php _e( 'Cache Type', 'pods' ); ?></label> 
  61. </td> 
  62. <td> 
  63. <?php 
  64. $cache_modes = array( 
  65. 'none' => __( 'Disable Caching', 'pods' ),  
  66. 'cache' => __( 'Object Cache', 'pods' ),  
  67. 'transient' => __( 'Transient', 'pods' ),  
  68. 'site-transient' => __( 'Site Transient', 'pods' ) 
  69. ); 
  70.  
  71. $form->add_drop_down( 'cache_mode', $cache_modes ); 
  72. ?> 
  73. </td> 
  74. </tr> 
  75. <tr> 
  76. <td valign="top"> 
  77. <label for="expires"><?php _e( 'Cache Expiration (in seconds)', 'pods' ); ?></label> 
  78. </td> 
  79. <td> 
  80. <?php $form->add_text_box( 'expires' ); ?> 
  81. </td> 
  82. </tr> 
  83. <?php 
  84.  
  85. /** 
  86. * Module Output 
  87. */ 
  88. function _render ( $fields ) { 
  89. $args = array( 
  90. 'view' => trim( pods_var_raw( 'view', $fields[ 'data' ], '' ) ),  
  91. 'expires' => (int) trim( pods_var_raw( 'expires', $fields[ 'data' ], ( 60 * 5 ) ) ),  
  92. 'cache_mode' => trim( pods_var_raw( 'cache_mode', $fields[ 'data' ], 'transient', null, true ) ) 
  93. ); 
  94.  
  95. if ( 0 < strlen( $args[ 'view' ] ) && 'none' != $args[ 'cache_mode' ] ) 
  96. echo pods_shortcode( $args ); 
  97.