Changeset 1403786
- Timestamp:
- 04/25/2016 01:43:06 PM (10 years ago)
- Location:
- cf7-mgtsk-add/trunk
- Files:
-
- 3 edited
-
cf7_mgtsk_add.php (modified) (2 diffs)
-
includes/cf7_mgtsk_Helper.php (modified) (1 diff)
-
includes/cf7_mgtsk_List_Table.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cf7-mgtsk-add/trunk/cf7_mgtsk_add.php
r1389137 r1403786 5 5 Depends: Contact From 7 6 6 Description: Плагин для интеграции CMS Wordpress и CRM Мегаплана. Работает как дополнение к основному плагину contactform7. Все формы, созданные через плагин, автоматически интегрируются с вашей CRM. 7 Version: 1.0. 17 Version: 1.0.2 8 8 Author: sadesign 9 9 Author URI: http://sadesign.pro … … 312 312 $valueCommentRaw[] = array( 313 313 'name' => __('form_title', 'cf7_mgtsk_add'), 314 'value' => $object->title 314 'value' => $object->title() 315 315 ); 316 316 $valueEmailRaw = array(); -
cf7-mgtsk-add/trunk/includes/cf7_mgtsk_Helper.php
r1388987 r1403786 11 11 * @author arizona 12 12 */ 13 class cf7_mgtsk_Helper { 13 class cf7_mgtsk_Helper 14 { 14 15 15 public static function cleanFormContent($cRaw) { 16 $cClean = cf7_mgtsk_Helper::cleanFormContentRegexp($cRaw); 17 $c = array(); 18 foreach ($cClean[1] as $i => $raw) { 19 $raw = cf7_mgtsk_Helper::cleanFormLineRaw($raw); 20 $field = explode(' ', $raw); 16 public static function cleanFormContent($cRaw) 17 { 18 $cClean = cf7_mgtsk_Helper::cleanFormContentRegexp($cRaw); 19 $c = array(); 20 foreach ($cClean[1] as $i => $raw) { 21 $raw = cf7_mgtsk_Helper::cleanFormLineRaw($raw); 22 $field = explode(' ', $raw); 21 23 22 $type = $field[0]; 23 $name = $field[1]; 24 25 if ($type == 'submit') { 26 continue; 27 } 28 29 if (array_search('placeholder', $field)) { 30 $display_name = $field[array_search('placeholder', $field) + 1]; 31 $display_name = str_replace('_', ' ', $display_name); 32 } else { 33 $display_name = ''; 34 } 35 36 $required = 0; 37 if (preg_match('/\*$/', $type) > 0) { 38 $required = 1; 39 $type = preg_replace('/\*$/', '', $type); 40 } 41 42 $c[$i] = array( 43 'type' => $type, 44 'required' => $required, 45 'name' => $name, 46 ); 47 if(!empty($display_name)) { 48 $c[$i]['display_name'] = $display_name; 49 } 24 $type = $field[0]; 25 $name = $field[1]; 26 27 if ($type == 'submit') { 28 continue; 29 } 30 31 $display_name = ''; 32 if (array_search('placeholder', $field)) { 33 $display_name = $field[array_search('placeholder', $field) + 1]; 34 $display_name = str_replace('_', ' ', $display_name); 35 } 36 37 $required = 0; 38 if (preg_match('/\*$/', $type) > 0) { 39 $required = 1; 40 $type = preg_replace('/\*$/', '', $type); 41 } 42 43 $c[$i] = array( 44 'type' => $type, 45 'required' => $required, 46 'name' => $name, 47 'display_name' => $display_name 48 ); 49 } 50 return $c; 51 } 52 53 public static function cleanFormContentRegexp($cRaw) 54 { 55 $pattern = '/\[(.*?)\]/m'; 56 preg_match_all($pattern, $cRaw, $cClean); 57 return $cClean; 58 } 59 60 public static function cleanFormLineRaw($lRaw) 61 { 62 preg_match_all('/"(.*?)"/', $lRaw, $string); 63 if (!empty($string[1])) { 64 $replacement = str_replace(' ', '_', $string[1][0]); 65 $lRaw = preg_replace('/"(.*?)"/', $replacement, $lRaw); 66 } 67 return $lRaw; 68 } 69 70 public static function showTable($c, $use_mgtsk) 71 { 72 ob_start(); 73 ?> 74 <table class="table-small table-properties"> 75 <thead> 76 <tr> 77 <td><?php _e('type', 'cf7_mgtsk_add'); ?></td> 78 <?php if (1 == 0) { ?> 79 <td>*</td> 80 <?php } ?> 81 <td><?php _e('name', 'cf7_mgtsk_add'); ?></td> 82 <td><?php _e('display_name', 'cf7_mgtsk_add'); ?></td> 83 </tr> 84 </thead> 85 <tbody> 86 <?php 87 foreach ($c as $row) { 88 $class = array(); 89 if ($row['required'] == 1) { 90 $class[] = 'required'; 50 91 } 51 return $c; 92 if ($use_mgtsk == true) { 93 $re = "/(email|phone)/"; 94 $str = $row['name']; 95 preg_match($re, $str, $matches); 96 97 if (count($matches) > 0) { 98 // $class[] = 'field'; 99 } 100 } 101 ?> 102 <tr class="<?php echo implode(' ', $class); ?>"> 103 <td><?php echo $row['type']; ?></td> 104 <?php if (1 == 0) { ?> 105 <td><?php echo $row['required']; ?></td> 106 <?php } ?> 107 <td><?php echo $row['name']; ?></td> 108 <td><?php echo $row['display_name']; ?></td> 109 </tr> 110 <?php 111 } 112 ?> 113 </tbody> 114 </table> 115 <?php 116 return ob_get_clean(); 117 } 118 119 public static function streamComment($arr) 120 { 121 $resultRaw = array(); 122 foreach ($arr as $line) { 123 if (empty($line['name'])) { 124 $resultRaw[] = $line['value']; 125 } else { 126 $resultRaw[] = $line['name'] . ': ' . $line['value']; 127 } 52 128 } 53 54 public static function cleanFormContentRegexp($cRaw) { 55 $pattern = '/\[(.*?)\]/m'; 56 preg_match_all($pattern, $cRaw, $cClean); 57 return $cClean; 58 } 59 60 public static function cleanFormLineRaw($lRaw) { 61 preg_match_all('/"(.*?)"/', $lRaw, $string); 62 if (!empty($string[1])) { 63 $replacement = str_replace(' ', '_', $string[1][0]); 64 $lRaw = preg_replace('/"(.*?)"/', $replacement, $lRaw); 65 } 66 return $lRaw; 67 } 68 69 public static function showTable($c, $use_mgtsk) { 70 ob_start(); 71 ?> 72 <table class="table-small table-properties"> 73 <thead> 74 <tr> 75 <td><?php _e('type', 'cf7_mgtsk_add'); ?></td> 76 <!-- <td>*</td>--> 77 <td><?php _e('name', 'cf7_mgtsk_add'); ?></td> 78 <td><?php _e('display_name', 'cf7_mgtsk_add'); ?></td> 79 </tr> 80 </thead> 81 <tbody> 82 <?php 83 foreach ($c as $row) { 84 $class = array(); 85 if ($row['required'] == 1) { 86 $class[] = 'required'; 87 } 88 if ($use_mgtsk == true) { 89 $re = "/(email|phone)/"; 90 $str = $row['name']; 91 preg_match($re, $str, $matches); 92 93 if (count($matches) > 0) { 94 // $class[] = 'field'; 95 } 96 } 97 ?> 98 <tr class="<?php echo implode(' ', $class); ?>"> 99 <td><?php echo $row['type']; ?></td> 100 <!-- <td>--><?php //echo $row['required']; ?><!--</td>--> 101 <td><?php echo $row['name']; ?></td> 102 <td><?php echo $row['display_name']; ?></td> 103 </tr> 104 <?php 105 } 106 ?> 107 </tbody> 108 </table> 109 <?php 110 return ob_get_clean(); 111 } 112 113 public static function streamComment($arr) { 114 $resultRaw = array(); 115 foreach ($arr as $line) { 116 if (empty($line['name'])) { 117 $resultRaw[] = $line['value']; 118 } else { 119 $resultRaw[] = $line['name'] . ': ' . $line['value']; 120 } 121 } 122 return(implode('<br/>', $resultRaw)); 123 } 129 return (implode('<br/>', $resultRaw)); 130 } 124 131 125 132 } -
cf7-mgtsk-add/trunk/includes/cf7_mgtsk_List_Table.php
r1388987 r1403786 24 24 25 25 function column_use_mgtsk($item) { 26 $meta = get_post_meta($item->id , 'use_mgtsk', 1);26 $meta = get_post_meta($item->id(), 'use_mgtsk', 1); 27 27 if (!empty($meta)) { 28 28 $checked = 'checked="checked"'; … … 32 32 $value = 0; 33 33 } 34 return "<input type='checkbox' name='use_mgtsk' data-id='{$item->id }' value='{$value}' {$checked} />";34 return "<input type='checkbox' name='use_mgtsk' data-id='{$item->id()}' value='{$value}' {$checked} />"; 35 35 } 36 36 37 37 function column_fields($item) { 38 $meta = get_post_meta($item->id , 'use_mgtsk', 1);38 $meta = get_post_meta($item->id(), 'use_mgtsk', 1); 39 39 $cRaw = $item->prop('form'); 40 40 $c = cf7_mgtsk_Helper::cleanFormContent($cRaw);
Note: See TracChangeset
for help on using the changeset viewer.