PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.7
Pods – Custom Content Types and Fields v3.2.7
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / components / Builder / modules / view / PodsBuilderModuleView.php
pods / components / Builder / modules / view Last commit date
images 13 years ago PodsBuilderModuleView.php 3 years ago
PodsBuilderModuleView.php
132 lines
1 <?php
2 /**
3 * @package Pods\Components
4 * @subpackage Builder
5 */
6 if ( ! class_exists( 'LayoutModule' ) ) {
7 return;
8 }
9
10 if ( ! class_exists( 'PodsBuilderModuleView' ) ) {
11 /**
12 * Class PodsBuilderModuleView
13 */
14 class PodsBuilderModuleView extends LayoutModule {
15
16 public $_name = '';
17 public $_var = 'pods-builder-view';
18 public $_description = '';
19 public $_editor_width = 500;
20 public $_can_remove_wrappers = true;
21
22 /**
23 * Register the Module
24 */
25 public function __construct() {
26
27 $this->_name = __( 'Pods - View', 'pods' );
28 $this->_description = __( 'Include a file from a theme, with caching options', 'pods' );
29 $this->module_path = dirname( __FILE__ );
30
31 $this->LayoutModule();
32 }
33
34 /**
35 * Set default variables
36 *
37 * @param $defaults
38 *
39 * @return mixed
40 */
41 public function _get_defaults( $defaults ) {
42
43 $new_defaults = array(
44 'view' => '',
45 'expires' => 0,
46 'cache_mode' => 'none',
47 );
48
49 return ITUtility::merge_defaults( $new_defaults, $defaults );
50 }
51
52 /**
53 * Output something before the table form
54 *
55 * @param object $form Form class
56 * @param bool $results
57 */
58 public function _before_table_edit( $form, $results = true ) {
59
60 ?>
61 <p><?php echo $this->_description; ?></p>
62 <?php
63 }
64
65 /**
66 * Output something at the start of the table form
67 *
68 * @param object $form Form class
69 * @param bool $results
70 */
71 public function _start_table_edit( $form, $results = true ) {
72
73 ?>
74 <tr>
75 <td valign="top">
76 <label for="view"><?php _e( 'File to include', 'pods' ); ?></label>
77 </td>
78 <td>
79 <?php $form->add_text_box( 'view' ); ?>
80 </td>
81 </tr>
82 <tr>
83 <td valign="top">
84 <label for="cache_mode"><?php _e( 'Cache Type', 'pods' ); ?></label>
85 </td>
86 <td>
87 <?php
88 $cache_modes = array(
89 'none' => __( 'Disable Caching', 'pods' ),
90 'cache' => __( 'Object Cache', 'pods' ),
91 'transient' => __( 'Transient', 'pods' ),
92 'site-transient' => __( 'Site Transient', 'pods' ),
93 );
94
95 $form->add_drop_down( 'cache_mode', $cache_modes );
96 ?>
97 </td>
98 </tr>
99 <tr>
100 <td valign="top">
101 <label for="expires"><?php _e( 'Cache Expiration (in seconds)', 'pods' ); ?></label>
102 </td>
103 <td>
104 <?php $form->add_text_box( 'expires' ); ?>
105 </td>
106 </tr>
107 <?php
108 }
109
110 /**
111 * Module Output
112 *
113 * @param $fields
114 */
115 public function _render( $fields ) {
116
117 $args = array(
118 'view' => trim( (string) pods_var_raw( 'view', $fields['data'], '' ) ),
119 'expires' => (int) trim( (string) pods_var_raw( 'expires', $fields['data'], ( 60 * 5 ) ) ),
120 'cache_mode' => trim( (string) pods_var_raw( 'cache_mode', $fields['data'], 'transient', null, true ) ),
121 );
122
123 if ( 0 < strlen( $args['view'] ) && 'none' !== $args['cache_mode'] ) {
124 echo pods_shortcode( $args );
125 }
126 }
127
128 }
129 }//end if
130
131 new PodsBuilderModuleView();
132