/template-row.php

  1. <?php 
  2.  
  3.  
  4. if ( is_array( $leads ) && ! empty( $leads ) && sizeof( $leads ) > 0 && $lead_count > 0 ) { 
  5.  
  6. $field_ids = array_keys( $columns ); 
  7.  
  8. $evenodd = ''; 
  9. foreach ( $leads as $lead ) { 
  10. echo "\n\t\t\t\t\t\t"; 
  11.  
  12. $address = array(); 
  13. $celltitle = ''; 
  14.  
  15. if ( $approved ) { 
  16. $leadapproved = self::check_approval( $lead, $approvedcolumn ); 
  17.  
  18. if ( ( isset( $leadapproved ) && $leadapproved && $approved ) || ! $approved ) { 
  19.  
  20. $target = ( $linknewwindow && empty( $lightboxsettings['images'] ) ) ? ' target="_blank"' : ''; 
  21. $valignattr = ( $valign && $directoryview == 'table' ) ? ' valign="' . $valign . '"' : ''; 
  22. $nofollow = $nofollowlinks ? ' rel="nofollow"' : ''; 
  23. $evenodd = apply_filters( 'kws_gf_directory_evenodd', ( $evenodd == ' odd' ) ? ' even' : ' odd' ); 
  24. $rowstyle = ! empty( $rowstyle ) ? ' style="' . $rowstyle . '"' : ''; 
  25.  
  26. ?> 
  27. <tr id="lead_row_<?php echo $lead["id"] ?>" class='<?php echo trim( $rowclass . $evenodd ); 
  28. echo $lead["is_starred"] ? " featured" : "" ?>'<?php echo $rowstyle . $valignattr; ?>><?php 
  29. $class = ""; 
  30. $is_first_column = true; 
  31.  
  32. foreach ( $field_ids as $field_id ) { 
  33.  
  34. $field = RGFormsModel::get_field( $form, $field_id ); 
  35.  
  36. $lightboxclass = ''; 
  37.  
  38. if ( ! empty( $lightboxsettings['images'] ) ) { 
  39. if ( wp_script_is( 'colorbox', 'registered' ) ) { 
  40. $lightboxclass = ' class="colorbox lightbox"'; 
  41. } else if ( wp_script_is( 'thickbox', 'registered' ) ) { 
  42. $lightboxclass = ' class="thickbox lightbox"'; 
  43.  
  44. $value = RGFormsModel::get_lead_field_value( $lead, $field ); 
  45. $display_value = $value; 
  46.  
  47. /** 
  48. * @since 3.6.3 
  49. */ 
  50. if ( apply_filters( 'kws_gf_directory_format_value', true ) ) { 
  51. $display_value = GFCommon::get_lead_field_display( $field, $value, $lead["currency"] ); 
  52. $display_value = apply_filters( "gform_entry_field_value", $display_value, $field, $lead, $form ); 
  53.  
  54. // `id`, `ip`, etc. 
  55. if ( ! is_numeric( $field_id ) ) { 
  56. $input_type = $field_id; 
  57. } elseif ( GFCommon::is_post_field( $field ) ) { 
  58. $input_type = $field['type']; 
  59. } else { 
  60. $input_type = RGFormsModel::get_input_type( $field ); 
  61.  
  62. switch ( $input_type ) { 
  63.  
  64. case "business_hours": 
  65. $value = $display_value; 
  66. break; 
  67.  
  68. case "address" : 
  69. case "radio" : 
  70. case "checkbox" : 
  71. case "name": 
  72.  
  73. $value = $display_value; 
  74.  
  75. // Displaying just one input, not a complex field value 
  76. if ( floatval( $field_id ) !== floor( floatval( $field_id ) ) ) { 
  77. // We're appending this to the end. 
  78. if ( $input_type === 'address' && $appendaddress ) { 
  79. $address['id'] = floor( (int) $field_id ); 
  80. $address[ $field_id ] = $value; 
  81. if ( $hideaddresspieces ) { 
  82. $value = NULL; 
  83. } else { 
  84.  
  85. //looping through lead detail values trying to find an item identical to the column label. Mark with a tick if found. 
  86. $lead_field_keys = array_keys( $lead ); 
  87. foreach ( $lead_field_keys as $input_id ) { 
  88. //mark as a tick if input label (from form meta) is equal to submitted value (from lead) 
  89. if ( is_numeric( $input_id ) && floatval( $input_id ) === floatval( $field_id ) ) { 
  90. if ( $lead[ $input_id ] == $field["label"] ) { 
  91. $value = apply_filters( 'kws_gf_directory_tick', sprintf( "<img src='" . GFCommon::get_base_url() . "/images/tick.png' alt='%s' />", esc_html( $lead[ $input_id ] ) ), $lead, $field ); 
  92. } else { 
  93. $value = $lead[ $input_id ]; 
  94. break; 
  95.  
  96. case "fileupload" : 
  97.  
  98. // Multi-file uploads are stored as JSON array. Single images are URLs 
  99. $images = json_decode( $value, true ); 
  100.  
  101. // Only one image, not array of JSON-encoded images 
  102. if ( ! is_array( $images ) ) { 
  103. $images = array( $value ); 
  104.  
  105. $image_output = array(); 
  106. foreach ( $images as $key => $url ) { 
  107. if ( ! empty( $url ) ) { 
  108. $image_output[] = GFDirectory::render_image_link( $url, $lead, $options ); 
  109.  
  110. if ( sizeof( $image_output ) > 1 ) { 
  111. $value = '<ul><li>' . implode( '</li><li>', $image_output ) . '</li></ul>'; 
  112. } else { 
  113. $value = implode( '', $image_output ); 
  114.  
  115. break; 
  116. case "post_image" : 
  117.  
  118. $valueArray = explode( "|:|", $value ); 
  119.  
  120. @list( $url, $title, $caption, $description ) = $valueArray; 
  121.  
  122. if ( ! empty( $url ) ) { 
  123. $value = GFDirectory::render_image_link( $url, $lead, $options, $title, $caption, $description ); 
  124. break; 
  125.  
  126. case "source_url" : 
  127. if ( in_array( 'urls', $lightboxsettings ) || ! empty( $lightboxsettings['urls'] ) ) { 
  128. $lightboxclass .= ' rel="directory_all directory_urls"'; 
  129. if ( $linkwebsite ) { 
  130. $value = "<a href='" . esc_attr( $lead["source_url"] ) . "'{$target}{$lightboxclass} title='" . esc_attr( $lead["source_url"] ) . "'$nofollow>.../" . esc_attr( GFCommon::truncate_url( $lead["source_url"] ) ) . "</a>"; 
  131. } else { 
  132. $value = esc_attr( GFCommon::truncate_url( $lead["source_url"] ) ); 
  133. break; 
  134.  
  135. case "post_title": 
  136. if ( apply_filters( 'kws_gf_directory_post_title_link', false, $form, $lead ) && ! empty( $lead['post_id'] ) ) { 
  137. $value = '<a href="' . esc_url( get_permalink( $lead['post_id'] ) ) . '" title="' . esc_attr( $value ) . '" ' . $nofollow . $target . '>' . esc_html( $value ) . '</a>'; 
  138. } else { 
  139. $value = esc_html( $value ); 
  140. break; 
  141.  
  142. case "textarea" : 
  143. case "post_content" : 
  144. case "post_excerpt" : 
  145. $value = wpautop( $value ); 
  146. break; 
  147.  
  148. case "post_category": 
  149. if( $value ) { 
  150. $value = GFCommon::prepare_post_category_value( $value, $field, 'entry_list' ); 
  151. break; 
  152.  
  153. case "date_created" : 
  154. $value = GFCommon::format_date( $lead['date_created'], true, apply_filters( 'kws_gf_date_format', '' ) ); 
  155. break; 
  156.  
  157. case "date" : 
  158. if ( $dateformat ) { 
  159. $value = GFCommon::date_display( $value, $dateformat ); 
  160. } else { 
  161. $value = GFCommon::date_display( $value, $field["dateFormat"] ); 
  162. break; 
  163.  
  164. case "id" : 
  165. $linkClass = ''; 
  166. break; 
  167.  
  168. case "list": 
  169. $value = GFCommon::get_lead_field_display( $field, $value ); 
  170. break; 
  171.  
  172. default: 
  173. $input_type = 'text'; 
  174.  
  175. if ( is_email( $value ) && $linkemail ) { 
  176. $value = "<a href='mailto:$value'$nofollow>$value</a>"; 
  177. } elseif ( preg_match( '|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $value ) && $linkwebsite ) { 
  178. $href = $value; 
  179. if ( ! empty( $lightboxsettings['images'] ) ) { 
  180. if ( in_array( 'urls', $lightboxsettings ) || ! empty( $lightboxsettings['urls'] ) ) { 
  181. $lightboxclass .= ' rel="directory_all directory_urls"'; 
  182. $linkClass = $lightboxclass; 
  183. } else { 
  184. $linkClass = isset( $linkClass ) ? $linkClass : ''; 
  185. if ( $truncatelink ) { 
  186. $value = apply_filters( 'kws_gf_directory_anchor_text', $value ); 
  187. $value = "<a href='{$href}'{$nofollow}{$target}{$linkClass}>{$value}</a>"; 
  188. if ( $is_first_column ) { 
  189. echo "\n"; 
  190. if ( $value !== NULL ) { 
  191. if ( isset( $columns["{$field_id}"]['label'] ) && $hovertitle || $directoryview !== 'table' ) { 
  192. $celltitle = ' title="' . esc_html( apply_filters( 'kws_gf_directory_th', apply_filters( 'kws_gf_directory_th_' . $field_id, apply_filters( 'kws_gf_directory_th_' . sanitize_title( $columns["{$field_id}"]['label'] ), $columns["{$field_id}"]['label'] ) ) ) ) . '"'; 
  193. } else { 
  194. $celltitle = ''; 
  195. echo "\t\t\t\t\t\t\t"; ?> 
  196. <td<?php echo ' class="' . $input_type . '"'; 
  197. echo $valignattr; 
  198. echo $celltitle; ?>><?php 
  199.  
  200.  
  201. $value = empty( $value ) ? ' ' : $value; 
  202.  
  203. // If the current field is the ID 
  204. if ( isset( $entrylinkcolumns[ floor( $field_id ) ] ) || isset( $entrylinkcolumns['id'] ) && $input_type == 'id' ) { 
  205.  
  206. if ( $input_type == 'id' && $entry ) { 
  207. $linkvalue = $entrylink; 
  208. } else { 
  209. $type = $entrylinkcolumns[ floor( $field_id ) ]; 
  210. if ( $type === 'label' ) { 
  211. $linkvalue = $columns["{$field_id}"]['label']; 
  212. } elseif ( ! empty( $type ) && $type !== 'on' ) { 
  213. $linkvalue = str_replace( '%value%', $value, $type ); 
  214. } else { 
  215. $linkvalue = $value; 
  216. $value = self::make_entry_link( $options, $linkvalue, $lead['id'], $form_id, $field_id ); 
  217.  
  218. $value = apply_filters( 'kws_gf_directory_value', apply_filters( 'kws_gf_directory_value_' . $input_type, apply_filters( 'kws_gf_directory_value_' . $field_id, $value ) ) ); 
  219.  
  220. echo $value; 
  221.  
  222. ?></td><?php 
  223. echo "\n"; 
  224. $is_first_column = false; 
  225.  
  226. if ( is_array( $address ) && ! empty( $address ) && $appendaddress ) { 
  227. $address = apply_filters( 'kws_gf_directory_td_address', $address, $linknewwindow ); 
  228. if ( ! is_array( $address ) ) { 
  229. echo "\t\t\t\t\t\t\t" . '<td class="address" title="' . esc_html( apply_filters( 'kws_gf_directory_th', apply_filters( 'kws_gf_directory_th_address', 'Address' ) ) ) . '">' . $address . '</td>'; 
  230.  
  231. ?> 
  232. </tr> 
  233. <?php } 
  234. } else { 
  235. ?> 
  236. <tr> 
  237. <td colspan="<?php echo sizeof( $columns ); ?>" class="noresults" style="padding:20px;"><?php 
  238.  
  239. if ( $search_query ) { 
  240. _e( "This search returned no results.", "gravity-forms-addons" ); 
  241. } elseif ( $limituser ) { 
  242. _e( "This form does not have any visible entries.", "gravity-forms-addons" ); 
  243. } else { 
  244. _e( "This form does not have any entries yet.", "gravity-forms-addons" ); 
  245.  
  246. ?></td> 
  247. </tr> 
  248. <?php 
  249. ?> 
.